From 8a47f2b273929dedcf620d327f6411ef2847f409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Wed, 28 Feb 2024 13:37:12 -0500 Subject: [PATCH 1/5] Replace list of glob by single glob and add size to volume specs --- aws/infrastructure.tf | 5 ++++- azure/infrastructure.tf | 5 ++++- gcp/infrastructure.tf | 5 ++++- openstack/infrastructure.tf | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/aws/infrastructure.tf b/aws/infrastructure.tf index 38435ba2..520fecba 100644 --- a/aws/infrastructure.tf +++ b/aws/infrastructure.tf @@ -200,7 +200,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => ["/dev/disk/by-id/*${replace(aws_ebs_volume.volumes["${x}-${pv_key}-${name}"].id, "-", "")}"] + name => { + glob = "/dev/disk/by-id/*${replace(aws_ebs_volume.volumes["${x}-${pv_key}-${name}"].id, "-", "")}" + size = specs.size + } } if contains(values.tags, pv_key) } : {} } diff --git a/azure/infrastructure.tf b/azure/infrastructure.tf index e03f859a..f064e484 100644 --- a/azure/infrastructure.tf +++ b/azure/infrastructure.tf @@ -163,7 +163,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => ["/dev/disk/azure/scsi1/lun${index(module.design.volume_per_instance[x], replace(pv_key, "${x}-", ""))}"] + name => { + glob = "/dev/disk/azure/scsi1/lun${index(module.design.volume_per_instance[x], replace(pv_key, "${x}-", ""))}" + size = specs.size + } } if contains(values.tags, pv_key) } : {} } diff --git a/gcp/infrastructure.tf b/gcp/infrastructure.tf index 2c29f7b6..2cc47f98 100644 --- a/gcp/infrastructure.tf +++ b/gcp/infrastructure.tf @@ -173,7 +173,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => ["/dev/disk/by-id/google-${var.cluster_name}-${x}-${pv_key}-${name}"] + name => { + glob = "/dev/disk/by-id/google-${var.cluster_name}-${x}-${pv_key}-${name}" + size = specs.size + } } if contains(values.tags, pv_key) } : {} } diff --git a/openstack/infrastructure.tf b/openstack/infrastructure.tf index c5029370..46f1f6d5 100644 --- a/openstack/infrastructure.tf +++ b/openstack/infrastructure.tf @@ -127,7 +127,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => ["/dev/disk/by-id/*${substr(openstack_blockstorage_volume_v3.volumes["${x}-${pv_key}-${name}"].id, 0, 20)}"] + name => { + glob = "/dev/disk/by-id/*${substr(openstack_blockstorage_volume_v3.volumes["${x}-${pv_key}-${name}"].id, 0, 20)}" + size = specs.size + } } if contains(values.tags, pv_key) } : {} } From b6fe18d0db31f973644be09219fab68340ac3e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Wed, 28 Feb 2024 14:18:51 -0500 Subject: [PATCH 2/5] Move specs to volumes terraform_data --- aws/infrastructure.tf | 8 ++++---- azure/infrastructure.tf | 8 ++++---- gcp/infrastructure.tf | 8 ++++---- openstack/infrastructure.tf | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/aws/infrastructure.tf b/aws/infrastructure.tf index 520fecba..367477c9 100644 --- a/aws/infrastructure.tf +++ b/aws/infrastructure.tf @@ -200,10 +200,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => { - glob = "/dev/disk/by-id/*${replace(aws_ebs_volume.volumes["${x}-${pv_key}-${name}"].id, "-", "")}" - size = specs.size - } + name => merge( + { glob = "/dev/disk/by-id/*${replace(aws_ebs_volume.volumes["${x}-${pv_key}-${name}"].id, "-", "")}" }, + specs, + ) } if contains(values.tags, pv_key) } : {} } diff --git a/azure/infrastructure.tf b/azure/infrastructure.tf index f064e484..fada534a 100644 --- a/azure/infrastructure.tf +++ b/azure/infrastructure.tf @@ -163,10 +163,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => { - glob = "/dev/disk/azure/scsi1/lun${index(module.design.volume_per_instance[x], replace(pv_key, "${x}-", ""))}" - size = specs.size - } + name => merge( + { glob = "/dev/disk/azure/scsi1/lun${index(module.design.volume_per_instance[x], replace(pv_key, "${x}-", ""))}" }, + specs, + ) } if contains(values.tags, pv_key) } : {} } diff --git a/gcp/infrastructure.tf b/gcp/infrastructure.tf index 2cc47f98..d946f160 100644 --- a/gcp/infrastructure.tf +++ b/gcp/infrastructure.tf @@ -173,10 +173,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => { - glob = "/dev/disk/by-id/google-${var.cluster_name}-${x}-${pv_key}-${name}" - size = specs.size - } + name => merge( + { glob = "/dev/disk/by-id/google-${var.cluster_name}-${x}-${pv_key}-${name}"}, + specs, + ) } if contains(values.tags, pv_key) } : {} } diff --git a/openstack/infrastructure.tf b/openstack/infrastructure.tf index 46f1f6d5..5bd4deb4 100644 --- a/openstack/infrastructure.tf +++ b/openstack/infrastructure.tf @@ -127,10 +127,10 @@ locals { for pv_key, pv_values in var.volumes: pv_key => { for name, specs in pv_values: - name => { - glob = "/dev/disk/by-id/*${substr(openstack_blockstorage_volume_v3.volumes["${x}-${pv_key}-${name}"].id, 0, 20)}" - size = specs.size - } + name => merge( + { glob = "/dev/disk/by-id/*${substr(openstack_blockstorage_volume_v3.volumes["${x}-${pv_key}-${name}"].id, 0, 20)}" }, + specs, + ) } if contains(values.tags, pv_key) } : {} } From 88706ec5d6c6545d93cbb3b103c3cc72bd688a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Thu, 29 Feb 2024 15:20:11 -0500 Subject: [PATCH 3/5] Add autoresize option and docs --- docs/README.md | 30 ++++-------------------------- openstack/infrastructure.tf | 1 + 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/docs/README.md b/docs/README.md index a08260ca..babec4b9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1774,32 +1774,10 @@ Puppet data hierarchy. ### 10.15 Expand a volume -Volumes defined in the `volumes` map can be expanded at will. After their creation, you can -increase their size in the `main.tf` then call `terraform apply` and the associated block -device will be expanded. - -To benefit from the new storage, the following commands need to be ran as root -on the instance to which the expanded volume is attached. -1. Identify the physical volume path - ``` - pvscan - ``` -2. Expand the physical volume - ```  - pvresize /dev/vdxyz # replace vdxyz by the volume identify at step 1 - ``` -3. Identify the volume group path - ```  - lvdisplay - ``` -4. Expand the volume group using step volume group path identified - ``` - lvextend -l '+100%FREE' -r /dev/project_vg/project - ``` -5. Resize the XFS fileystem: - ``` - xfs_growfs /dev/project_vg/project - ``` +Volumes defined in the `volumes` map can be expanded at will. To enable online extension of +a volume, add `autoresize = true` to its specs map. You can then increase the size at will. +The corresponding volume will be expanded by the cloud provider and the filesystem will be +extended by Puppet. ## 11. Customize Magic Castle Terraform Files diff --git a/openstack/infrastructure.tf b/openstack/infrastructure.tf index 5bd4deb4..37663907 100644 --- a/openstack/infrastructure.tf +++ b/openstack/infrastructure.tf @@ -100,6 +100,7 @@ resource "openstack_blockstorage_volume_v3" "volumes" { size = each.value.size volume_type = lookup(each.value, "type", null) snapshot_id = lookup(each.value, "snapshot", null) + enable_online_resize = lookup(each.value, "autoresize", null) } resource "openstack_compute_volume_attach_v2" "attachments" { From 0db9bc1dc725fb66c2f1df469d57e469e1ff6322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Thu, 29 Feb 2024 15:21:35 -0500 Subject: [PATCH 4/5] Make enable_online_resize false --- openstack/infrastructure.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstack/infrastructure.tf b/openstack/infrastructure.tf index 37663907..8ffe187a 100644 --- a/openstack/infrastructure.tf +++ b/openstack/infrastructure.tf @@ -100,7 +100,7 @@ resource "openstack_blockstorage_volume_v3" "volumes" { size = each.value.size volume_type = lookup(each.value, "type", null) snapshot_id = lookup(each.value, "snapshot", null) - enable_online_resize = lookup(each.value, "autoresize", null) + enable_online_resize = lookup(each.value, "autoresize", false) } resource "openstack_compute_volume_attach_v2" "attachments" { From 64bd4bd821cd085e219f49f6b8cfdb11ece57418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Thu, 29 Feb 2024 15:23:12 -0500 Subject: [PATCH 5/5] Rename autoresize to enable_resize --- docs/README.md | 2 +- openstack/infrastructure.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index babec4b9..b2fcca97 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1775,7 +1775,7 @@ Puppet data hierarchy. ### 10.15 Expand a volume Volumes defined in the `volumes` map can be expanded at will. To enable online extension of -a volume, add `autoresize = true` to its specs map. You can then increase the size at will. +a volume, add `enable_resize = true` to its specs map. You can then increase the size at will. The corresponding volume will be expanded by the cloud provider and the filesystem will be extended by Puppet. diff --git a/openstack/infrastructure.tf b/openstack/infrastructure.tf index 8ffe187a..e00342c4 100644 --- a/openstack/infrastructure.tf +++ b/openstack/infrastructure.tf @@ -100,7 +100,7 @@ resource "openstack_blockstorage_volume_v3" "volumes" { size = each.value.size volume_type = lookup(each.value, "type", null) snapshot_id = lookup(each.value, "snapshot", null) - enable_online_resize = lookup(each.value, "autoresize", false) + enable_online_resize = lookup(each.value, "enable_resize", false) } resource "openstack_compute_volume_attach_v2" "attachments" {