summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2025-08-29 15:44:31 +0200
committerjerome <jerome@xlinfo.fr>2025-08-29 15:44:31 +0200
commit724ac3e34834c62a4875df8ae5b9deda4f90d6c2 (patch)
treeec29c272f7b8f930bd28ff176077b0c3cbc00b0f
parent65ae07a224af9ccec066ea4f6bed826ee45641f8 (diff)
downloadincus-724ac3e34834c62a4875df8ae5b9deda4f90d6c2.tar.gz
incus-724ac3e34834c62a4875df8ae5b9deda4f90d6c2.zip
-rw-r--r--final/container.tf (renamed from final/debian.tf)7
-rw-r--r--final/rocky.tf27
-rw-r--r--final/terraform.tfvars8
-rw-r--r--final/variables.tf1
4 files changed, 13 insertions, 30 deletions
diff --git a/final/debian.tf b/final/container.tf
index c7dfe51..99c97f5 100644
--- a/final/debian.tf
+++ b/final/container.tf
@@ -1,7 +1,8 @@
-resource "incus_instance" "debian" {
- name = "webserver1"
+resource "incus_instance" "instance" {
+for_each = var.containers
+ name = "${each.key}"
project = "lamp"
- image = "images:debian/12/cloud"
+ image = "images:${each.value.image}"
wait_for {
type = "ipv4"
}
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 {}