From 3d37839934942e1755891820c97b526b5d385e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 5 Apr 2024 19:34:04 -0400 Subject: [PATCH 01/11] ansible: Add dedicated gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .gitignore | 3 --- ansible/.gitignore | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 ansible/.gitignore diff --git a/.gitignore b/.gitignore index bcb3634..e1ad4a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ *.pyc -ansible/data/* -ansible/hosts.yaml - *.tfstate *.tfstate.backup .terraform* diff --git a/ansible/.gitignore b/ansible/.gitignore new file mode 100644 index 0000000..15205e5 --- /dev/null +++ b/ansible/.gitignore @@ -0,0 +1,2 @@ +data/* +hosts.yaml From b1fef5ca144f0cbed0e0b74f18f0d860d8843715 Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:33:25 -0400 Subject: [PATCH 02/11] terraform: Add dedicated gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .gitignore | 4 ---- terraform/.gitignore | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 terraform/.gitignore diff --git a/.gitignore b/.gitignore index e1ad4a4..0d20b64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1 @@ *.pyc - -*.tfstate -*.tfstate.backup -.terraform* diff --git a/terraform/.gitignore b/terraform/.gitignore new file mode 100644 index 0000000..90771d9 --- /dev/null +++ b/terraform/.gitignore @@ -0,0 +1,4 @@ +.terraform/ +.terraform.lock.hcl +terraform.tfstate +terraform.tfstate.backup From d740fbc56274d0b1e04075ec2bc2d9bd9c445f39 Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:37:21 -0400 Subject: [PATCH 03/11] terraform: Setup modules Signed-off-by: Jarrod Urban --- terraform/main.tf | 18 ++++++++++++++++++ terraform/versions.tf | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 terraform/main.tf create mode 100644 terraform/versions.tf diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 0000000..677beeb --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,18 @@ +module "baremetal" { + source = "./baremetal-incus" + + project_name = "dev-incus-deploy" + instance_names = ["server01", "server02", "server03", "server04", "server05"] + image = "images:ubuntu/22.04" + memory = "4GiB" + storage_pool = "default" +} + +module "services" { + source = "./services" + + project_name = "dev-incus-deploy-services" + instance_names = ["ceph-mds01", "ceph-mds02", "ceph-mds03", "ceph-mgr01", "ceph-mgr02", "ceph-mgr03", "ceph-rgw01", "ceph-rgw02", "ceph-rgw03"] + image = "images:ubuntu/22.04" + storage_pool = "default" +} diff --git a/terraform/versions.tf b/terraform/versions.tf new file mode 100644 index 0000000..4934763 --- /dev/null +++ b/terraform/versions.tf @@ -0,0 +1,12 @@ +terraform { + required_version = ">=1.5.7" + required_providers { + incus = { + source = "lxc/incus" + version = ">=0.1.1" + } + } +} + +provider "incus" { +} From 7e5695a11ef0c6e67bf33e2d7091242d230f3497 Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:40:57 -0400 Subject: [PATCH 04/11] terraform: Split version requirements to separate file Signed-off-by: Jarrod Urban --- terraform/baremetal-incus/main.tf | 11 ----------- terraform/baremetal-incus/versions.tf | 9 +++++++++ terraform/services/main.tf | 11 ----------- terraform/services/versions.tf | 9 +++++++++ 4 files changed, 18 insertions(+), 22 deletions(-) create mode 100644 terraform/baremetal-incus/versions.tf create mode 100644 terraform/services/versions.tf diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index be56aca..92b6624 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -1,14 +1,3 @@ -terraform { - required_providers { - incus = { - source = "lxc/incus" - } - } -} - -provider "incus" { -} - variable "instance_names" { type = set(string) default = ["server01", "server02", "server03", "server04", "server05"] diff --git a/terraform/baremetal-incus/versions.tf b/terraform/baremetal-incus/versions.tf new file mode 100644 index 0000000..50d463c --- /dev/null +++ b/terraform/baremetal-incus/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">=1.5.7" + required_providers { + incus = { + source = "lxc/incus" + version = ">=0.1.1" + } + } +} diff --git a/terraform/services/main.tf b/terraform/services/main.tf index d58d27a..b3ab672 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -1,14 +1,3 @@ -terraform { - required_providers { - incus = { - source = "lxc/incus" - } - } -} - -provider "incus" { -} - variable "instance_names" { type = set(string) default = ["ceph-mds01", "ceph-mds02", "ceph-mds03", "ceph-mgr01", "ceph-mgr02", "ceph-mgr03", "ceph-rgw01", "ceph-rgw02", "ceph-rgw03"] diff --git a/terraform/services/versions.tf b/terraform/services/versions.tf new file mode 100644 index 0000000..50d463c --- /dev/null +++ b/terraform/services/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">=1.5.7" + required_providers { + incus = { + source = "lxc/incus" + version = ">=0.1.1" + } + } +} From a9c7898691126c8ea73289ae4a7dffd3836cec5f Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:41:20 -0400 Subject: [PATCH 05/11] terraform: Add lifecycle Signed-off-by: Jarrod Urban --- terraform/baremetal-incus/main.tf | 4 ++++ terraform/services/main.tf | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index 92b6624..a71df04 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -149,4 +149,8 @@ resource "incus_instance" "instances" { "source" = incus_volume.disk3[each.key].name } } + + lifecycle { + ignore_changes = [ running ] + } } diff --git a/terraform/services/main.tf b/terraform/services/main.tf index b3ab672..18fdd5b 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -56,4 +56,8 @@ resource "incus_instance" "instances" { type = "container" image = "images:ubuntu/22.04" profiles = ["default", incus_profile.profile.name] + + lifecycle { + ignore_changes = [ running ] + } } From 2b0518558753ac5dc3fc6c19f67bf702e645f1aa Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:43:13 -0400 Subject: [PATCH 06/11] terraform: Move variables Signed-off-by: Jarrod Urban --- terraform/baremetal-incus/main.tf | 5 ----- terraform/baremetal-incus/variables.tf | 19 +++++++++++++++++++ terraform/services/main.tf | 5 ----- terraform/services/variables.tf | 15 +++++++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 terraform/baremetal-incus/variables.tf create mode 100644 terraform/services/variables.tf diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index a71df04..f091a6c 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -1,8 +1,3 @@ -variable "instance_names" { - type = set(string) - default = ["server01", "server02", "server03", "server04", "server05"] -} - resource "incus_project" "project" { name = "dev-incus-deploy" description = "Project used to test incus-deploy" diff --git a/terraform/baremetal-incus/variables.tf b/terraform/baremetal-incus/variables.tf new file mode 100644 index 0000000..2cca72d --- /dev/null +++ b/terraform/baremetal-incus/variables.tf @@ -0,0 +1,19 @@ +variable "project_name" { + type = string +} + +variable "instance_names" { + type = set(string) +} + +variable "image" { + type = string +} + +variable "memory" { + type = string +} + +variable "storage_pool" { + type = string +} diff --git a/terraform/services/main.tf b/terraform/services/main.tf index 18fdd5b..cd80a6a 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -1,8 +1,3 @@ -variable "instance_names" { - type = set(string) - default = ["ceph-mds01", "ceph-mds02", "ceph-mds03", "ceph-mgr01", "ceph-mgr02", "ceph-mgr03", "ceph-rgw01", "ceph-rgw02", "ceph-rgw03"] -} - resource "incus_project" "project" { name = "dev-incus-deploy-services" description = "Project used to test incus-deploy services" diff --git a/terraform/services/variables.tf b/terraform/services/variables.tf new file mode 100644 index 0000000..22eb8e2 --- /dev/null +++ b/terraform/services/variables.tf @@ -0,0 +1,15 @@ +variable "project_name" { + type = string +} + +variable "instance_names" { + type = set(string) +} + +variable "image" { + type = string +} + +variable "storage_pool" { + type = string +} From 635806968ed4fe40b7645f2d065256671f78590d Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:44:57 -0400 Subject: [PATCH 07/11] terraform: Make use of variables Signed-off-by: Jarrod Urban --- terraform/baremetal-incus/main.tf | 22 +++++++++++----------- terraform/services/main.tf | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index f091a6c..1fe5a78 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -18,7 +18,7 @@ resource "incus_profile" "profile" { config = { "limits.cpu" = 4 - "limits.memory" = "4GiB" + "limits.memory" = var.memory } device { @@ -26,7 +26,7 @@ resource "incus_profile" "profile" { name = "root" properties = { - "pool" = "default" + "pool" = var.storage_pool "path" = "/" } } @@ -46,7 +46,7 @@ resource "incus_profile" "profile" { name = "disk4" properties = { - "pool" = "default" + "pool" = var.storage_pool "io.bus" = "nvme" "source" = incus_volume.disk4.name } @@ -59,7 +59,7 @@ resource "incus_volume" "disk1" { project = incus_project.project.name name = "${each.value}-disk1" description = "First CEPH OSD drive" - pool = "default" + pool = var.storage_pool content_type = "block" config = { "size" = "20GiB" @@ -72,7 +72,7 @@ resource "incus_volume" "disk2" { project = incus_project.project.name name = "${each.value}-disk2" description = "Second CEPH OSD drive" - pool = "default" + pool = var.storage_pool content_type = "block" config = { "size" = "20GiB" @@ -85,7 +85,7 @@ resource "incus_volume" "disk3" { project = incus_project.project.name name = "${each.value}-disk3" description = "Local storage drive" - pool = "default" + pool = var.storage_pool content_type = "block" config = { "size" = "50GiB" @@ -96,7 +96,7 @@ resource "incus_volume" "disk4" { project = incus_project.project.name name = "shared-disk" description = "Shared block storage" - pool = "default" + pool = var.storage_pool content_type = "block" config = { "size" = "50GiB" @@ -109,7 +109,7 @@ resource "incus_instance" "instances" { project = incus_project.project.name name = each.value type = "virtual-machine" - image = "images:ubuntu/22.04" + image = var.image profiles = ["default", incus_profile.profile.name] device { @@ -117,7 +117,7 @@ resource "incus_instance" "instances" { name = "disk1" properties = { - "pool" = "default" + "pool" = var.storage_pool "io.bus" = "nvme" "source" = incus_volume.disk1[each.key].name } @@ -128,7 +128,7 @@ resource "incus_instance" "instances" { name = "disk2" properties = { - "pool" = "default" + "pool" = var.storage_pool "io.bus" = "nvme" "source" = incus_volume.disk2[each.key].name } @@ -139,7 +139,7 @@ resource "incus_instance" "instances" { name = "disk3" properties = { - "pool" = "default" + "pool" = var.storage_pool "io.bus" = "nvme" "source" = incus_volume.disk3[each.key].name } diff --git a/terraform/services/main.tf b/terraform/services/main.tf index cd80a6a..327efdc 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -27,7 +27,7 @@ resource "incus_profile" "profile" { name = "root" properties = { - "pool" = "default" + "pool" = var.storage_pool "path" = "/" } } @@ -49,7 +49,7 @@ resource "incus_instance" "instances" { project = incus_project.project.name name = each.value type = "container" - image = "images:ubuntu/22.04" + image = var.image profiles = ["default", incus_profile.profile.name] lifecycle { From 953e1ec38c0c0e5593a71056f616268c43f89b06 Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:46:21 -0400 Subject: [PATCH 08/11] terraform: Use this as identifier Signed-off-by: Jarrod Urban --- terraform/baremetal-incus/main.tf | 18 +++++++++--------- terraform/services/main.tf | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index 1fe5a78..258d541 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -1,4 +1,4 @@ -resource "incus_project" "project" { +resource "incus_project" "this" { name = "dev-incus-deploy" description = "Project used to test incus-deploy" config = { @@ -11,8 +11,8 @@ resource "incus_project" "project" { } } -resource "incus_profile" "profile" { - project = incus_project.project.name +resource "incus_profile" "this" { + project = incus_project.this.name name = "cluster" description = "Profile to be used by the cluster VMs" @@ -56,7 +56,7 @@ resource "incus_profile" "profile" { resource "incus_volume" "disk1" { for_each = var.instance_names - project = incus_project.project.name + project = incus_project.this.name name = "${each.value}-disk1" description = "First CEPH OSD drive" pool = var.storage_pool @@ -69,7 +69,7 @@ resource "incus_volume" "disk1" { resource "incus_volume" "disk2" { for_each = var.instance_names - project = incus_project.project.name + project = incus_project.this.name name = "${each.value}-disk2" description = "Second CEPH OSD drive" pool = var.storage_pool @@ -82,7 +82,7 @@ resource "incus_volume" "disk2" { resource "incus_volume" "disk3" { for_each = var.instance_names - project = incus_project.project.name + project = incus_project.this.name name = "${each.value}-disk3" description = "Local storage drive" pool = var.storage_pool @@ -93,7 +93,7 @@ resource "incus_volume" "disk3" { } resource "incus_volume" "disk4" { - project = incus_project.project.name + project = incus_project.this.name name = "shared-disk" description = "Shared block storage" pool = var.storage_pool @@ -106,11 +106,11 @@ resource "incus_volume" "disk4" { resource "incus_instance" "instances" { for_each = var.instance_names - project = incus_project.project.name + project = incus_project.this.name name = each.value type = "virtual-machine" image = var.image - profiles = ["default", incus_profile.profile.name] + profiles = ["default", incus_profile.this.name] device { type = "disk" diff --git a/terraform/services/main.tf b/terraform/services/main.tf index 327efdc..7e430c1 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -1,4 +1,4 @@ -resource "incus_project" "project" { +resource "incus_project" "this" { name = "dev-incus-deploy-services" description = "Project used to test incus-deploy services" config = { @@ -11,8 +11,8 @@ resource "incus_project" "project" { } } -resource "incus_profile" "profile" { - project = incus_project.project.name +resource "incus_profile" "this" { + project = incus_project.this.name name = "services" description = "Profile to be used by the service containers" @@ -46,11 +46,11 @@ resource "incus_profile" "profile" { resource "incus_instance" "instances" { for_each = var.instance_names - project = incus_project.project.name + project = incus_project.this.name name = each.value type = "container" image = var.image - profiles = ["default", incus_profile.profile.name] + profiles = ["default", incus_profile.this.name] lifecycle { ignore_changes = [ running ] From ee05095d39f13d065f9e16a85a626f7ac29e0a47 Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:46:41 -0400 Subject: [PATCH 09/11] terraform: Rename the projects Signed-off-by: Jarrod Urban --- terraform/baremetal-incus/main.tf | 2 +- terraform/services/main.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index 258d541..5bd1c3d 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -1,5 +1,5 @@ resource "incus_project" "this" { - name = "dev-incus-deploy" + name = "baremetal" description = "Project used to test incus-deploy" config = { "features.images" = false diff --git a/terraform/services/main.tf b/terraform/services/main.tf index 7e430c1..f29ca87 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -1,5 +1,5 @@ resource "incus_project" "this" { - name = "dev-incus-deploy-services" + name = "services" description = "Project used to test incus-deploy services" config = { "features.images" = false From 5c955656e8983015586e915ea3036302e0ea2eb2 Mon Sep 17 00:00:00 2001 From: Jarrod Urban Date: Fri, 5 Apr 2024 19:46:49 -0400 Subject: [PATCH 10/11] terraform: Formatting Signed-off-by: Jarrod Urban --- terraform/baremetal-incus/main.tf | 4 ++-- terraform/services/main.tf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index 5bd1c3d..865332f 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -17,7 +17,7 @@ resource "incus_profile" "this" { description = "Profile to be used by the cluster VMs" config = { - "limits.cpu" = 4 + "limits.cpu" = "4" "limits.memory" = var.memory } @@ -99,7 +99,7 @@ resource "incus_volume" "disk4" { pool = var.storage_pool content_type = "block" config = { - "size" = "50GiB" + "size" = "50GiB" "security.shared" = "true" } } diff --git a/terraform/services/main.tf b/terraform/services/main.tf index f29ca87..84aa08a 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -17,8 +17,8 @@ resource "incus_profile" "this" { description = "Profile to be used by the service containers" config = { - "limits.cpu" = 1 - "limits.memory" = "1GiB" + "limits.cpu" = "1" + "limits.memory" = "1GiB" "limits.processes" = "1000" } From b6346272688785737d420cd109a06ec6d156aa6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 5 Apr 2024 19:53:04 -0400 Subject: [PATCH 11/11] terraform: Make use of the project_name variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- terraform/baremetal-incus/main.tf | 2 +- terraform/services/main.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/baremetal-incus/main.tf b/terraform/baremetal-incus/main.tf index 865332f..e85cad8 100644 --- a/terraform/baremetal-incus/main.tf +++ b/terraform/baremetal-incus/main.tf @@ -1,5 +1,5 @@ resource "incus_project" "this" { - name = "baremetal" + name = var.project_name description = "Project used to test incus-deploy" config = { "features.images" = false diff --git a/terraform/services/main.tf b/terraform/services/main.tf index 84aa08a..0574b26 100644 --- a/terraform/services/main.tf +++ b/terraform/services/main.tf @@ -1,5 +1,5 @@ resource "incus_project" "this" { - name = "services" + name = var.project_name description = "Project used to test incus-deploy services" config = { "features.images" = false