From 724ac3e34834c62a4875df8ae5b9deda4f90d6c2 Mon Sep 17 00:00:00 2001 From: jerome Date: Fri, 29 Aug 2025 15:44:31 +0200 Subject: module --- final/container.tf | 27 +++++++++++++++++++++++++++ final/debian.tf | 26 -------------------------- final/rocky.tf | 27 --------------------------- final/terraform.tfvars | 8 ++++++++ final/variables.tf | 1 + 5 files changed, 36 insertions(+), 53 deletions(-) create mode 100644 final/container.tf delete mode 100644 final/debian.tf delete mode 100644 final/rocky.tf create mode 100644 final/terraform.tfvars create mode 100644 final/variables.tf (limited to 'final') diff --git a/final/container.tf b/final/container.tf new file mode 100644 index 0000000..99c97f5 --- /dev/null +++ b/final/container.tf @@ -0,0 +1,27 @@ +resource "incus_instance" "instance" { +for_each = var.containers + name = "${each.key}" + project = "lamp" + image = "images:${each.value.image}" + wait_for { + type = "ipv4" + } + provisioner "local-exec" { + command = "./local_script ${self.ipv4_address} ${self.name}" + } + connection { + type = "ssh" + host = self.ipv4_address + user = "ansible" + private_key = file("~/.ssh/id_rsa") + + } + provisioner "remote-exec" { + inline = [ + "cloud-init status || true" + ] + } + depends_on = [ + incus_profile.lamp + ] +} diff --git a/final/debian.tf b/final/debian.tf deleted file mode 100644 index c7dfe51..0000000 --- a/final/debian.tf +++ /dev/null @@ -1,26 +0,0 @@ -resource "incus_instance" "debian" { - name = "webserver1" - project = "lamp" - image = "images:debian/12/cloud" - wait_for { - type = "ipv4" - } - provisioner "local-exec" { - command = "./local_script ${self.ipv4_address} ${self.name}" - } - connection { - type = "ssh" - host = self.ipv4_address - user = "ansible" - private_key = file("~/.ssh/id_rsa") - - } - provisioner "remote-exec" { - inline = [ - "cloud-init status || true" - ] - } - depends_on = [ - incus_profile.lamp - ] -} diff --git a/final/rocky.tf b/final/rocky.tf deleted file mode 100644 index 5b81b3f..0000000 --- a/final/rocky.tf +++ /dev/null @@ -1,27 +0,0 @@ -resource "incus_instance" "rocky" { - name = "webserver2" - project = "lamp" - image = "images:rockylinux/9/cloud" - wait_for { - type = "ipv4" - } - provisioner "local-exec" { - command = "./local_script ${self.ipv4_address} ${self.name}" - } - connection { - type = "ssh" - host = self.ipv4_address - user = "ansible" - private_key = file("~/.ssh/id_rsa") - - } - provisioner "remote-exec" { - inline = [ - "cloud-init status || true" - ] - } - depends_on = [ - incus_profile.lamp - ] -} - diff --git a/final/terraform.tfvars b/final/terraform.tfvars new file mode 100644 index 0000000..f4a88df --- /dev/null +++ b/final/terraform.tfvars @@ -0,0 +1,8 @@ +containers = { + debian :{ + image = "debian/12/cloud" + }, + rocky :{ + image = "rockylinux/9/cloud" + } +} diff --git a/final/variables.tf b/final/variables.tf new file mode 100644 index 0000000..1a8b47f --- /dev/null +++ b/final/variables.tf @@ -0,0 +1 @@ +variable containers {} -- cgit v1.2.3