Skip to content

Commit

Permalink
Make changes to image variable ignored after cluster is built
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd-ntrf committed Feb 17, 2020
1 parent e0882bd commit 6b9cbc9
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
18 changes: 18 additions & 0 deletions aws/infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ resource "aws_instance" "mgmt" {
Name = format("mgmt%d", count.index + 1)
}

lifecycle {
ignore_changes = [
ami
]
}

depends_on = [aws_internet_gateway.gw]
}

Expand Down Expand Up @@ -244,6 +250,12 @@ resource "aws_instance" "login" {
aws_security_group.allow_out_any.id,
]

lifecycle {
ignore_changes = [
ami
]
}

tags = {
Name = format("login%d", count.index + 1)
}
Expand Down Expand Up @@ -279,6 +291,12 @@ resource "aws_instance" "node" {
aws_security_group.allow_out_any.id,
]

lifecycle {
ignore_changes = [
ami
]
}

tags = {
Name = "node${count.index + 1}"
}
Expand Down
18 changes: 18 additions & 0 deletions azure/infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ resource "azurerm_virtual_machine" "login" {
os_profile_linux_config {
disable_password_authentication = true
}

lifecycle {
ignore_changes = [
storage_image_reference
]
}
}

resource "azurerm_virtual_machine" "mgmt" {
Expand Down Expand Up @@ -202,6 +208,12 @@ resource "azurerm_virtual_machine" "mgmt" {
os_profile_linux_config {
disable_password_authentication = true
}

lifecycle {
ignore_changes = [
storage_image_reference
]
}
}

resource "azurerm_managed_disk" "home" {
Expand Down Expand Up @@ -290,6 +302,12 @@ resource "azurerm_virtual_machine" "nodevm" {
os_profile_linux_config {
disable_password_authentication = true
}

lifecycle {
ignore_changes = [
storage_image_reference
]
}
}

locals {
Expand Down
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ should be mainly done through Puppet scripting. Image customization is mostly
envisioned as a way to accelerate the provisioning process by applying the
security patches and OS updates in advance.

**Post Build Modification Effect**: rebuild of all instances at next `terraform apply`.
**Post Build Modification Effect**: None - if this variable is modified, existing
instances will ignore the change and future instances will use the new value.

#### 4.4.1 AWS

Expand Down
17 changes: 16 additions & 1 deletion gcp/infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ resource "google_compute_instance" "mgmt" {
metadata_startup_script = file("${path.module}/install_cloudinit.sh")

lifecycle {
ignore_changes = [attached_disk]
ignore_changes = [
attached_disk,
boot_disk.initialize_params.image
]
}
}

Expand Down Expand Up @@ -157,6 +160,12 @@ resource "google_compute_instance" "login" {
}

metadata_startup_script = file("${path.module}/install_cloudinit.sh")

lifecycle {
ignore_changes = [
boot_disk.initialize_params.image
]
}
}

resource "google_compute_instance" "node" {
Expand Down Expand Up @@ -193,6 +202,12 @@ resource "google_compute_instance" "node" {
}

metadata_startup_script = file("${path.module}/install_cloudinit.sh")

lifecycle {
ignore_changes = [
boot_disk.initialize_params.image
]
}
}

resource "google_compute_firewall" "allow_all_internal" {
Expand Down
21 changes: 21 additions & 0 deletions openstack/infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ resource "openstack_compute_instance_v2" "mgmt" {
volume_size = block_device.value.volume_size
}
}

lifecycle {
ignore_changes = [
image_id,
block_device[0].uuid
]
}
}

resource "openstack_compute_volume_attach_v2" "va_home" {
Expand Down Expand Up @@ -182,6 +189,13 @@ resource "openstack_compute_instance_v2" "login" {
volume_size = block_device.value.volume_size
}
}

lifecycle {
ignore_changes = [
image_id,
block_device[0].uuid
]
}
}

resource "openstack_networking_port_v2" "port_node" {
Expand Down Expand Up @@ -226,6 +240,13 @@ resource "openstack_compute_instance_v2" "node" {
volume_size = block_device.value.volume_size
}
}

lifecycle {
ignore_changes = [
image_id,
block_device[0].uuid
]
}
}

locals {
Expand Down

0 comments on commit 6b9cbc9

Please sign in to comment.