From 37169cd7d9c6389394fed35d463c585daa34ffb5 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Wed, 29 Jun 2022 22:57:14 +0200 Subject: [PATCH 1/6] remove tags ffrom deployement add these tags in your template it's work faster Signed-off-by: GnomeZworc --- main.tf | 5 ----- 1 file changed, 5 deletions(-) diff --git a/main.tf b/main.tf index 644f4b0..5aa308f 100644 --- a/main.tf +++ b/main.tf @@ -58,11 +58,6 @@ resource "xenorchestra_vm" "bar" { size = var.disk_size * 1024 * 1024 * 1024 } - tags = [ - "Debian", - "Best Distro", - ] - // Override the default create timeout from 5 mins to 20. timeouts { create = "20m" From 8971469873fd7075d3bbc2bf027df58726686374 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Fri, 1 Jul 2022 18:40:17 +0200 Subject: [PATCH 2/6] change xenorchestra_vm variable Signed-off-by: GnomeZworc --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 681cb75..1d4bb9e 100644 --- a/main.tf +++ b/main.tf @@ -31,7 +31,7 @@ data "xenorchestra_template" "template" { } -resource "xenorchestra_vm" "bar" { +resource "xenorchestra_vm" "vm_deployed" { memory_max = var.ram * 1024 * 1024 * 1024 cpus = var.cpu cloud_config = templatefile("cloud_config.tftpl", { @@ -75,7 +75,7 @@ EOF } resource "time_sleep" "wait_30_seconds" { - depends_on = [xenorchestra_vm.bar] + depends_on = [xenorchestra_vm.vm_deployed] create_duration = "30s" } From 268a346a1947e2adcb8d659b9704d14a07c35bf4 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Fri, 1 Jul 2022 18:48:48 +0200 Subject: [PATCH 3/6] add the option to add tags at deployement I made this things a vars Signed-off-by: GnomeZworc --- main.tf | 2 ++ var.tf | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/main.tf b/main.tf index 1d4bb9e..bca776c 100644 --- a/main.tf +++ b/main.tf @@ -58,6 +58,8 @@ resource "xenorchestra_vm" "vm_deployed" { size = var.disk_size * 1024 * 1024 * 1024 } + tags = var.vm_tags + // Override the default create timeout from 5 mins to 20. timeouts { create = "20m" diff --git a/var.tf b/var.tf index 4d4144d..9661ab0 100644 --- a/var.tf +++ b/var.tf @@ -93,3 +93,7 @@ variable "disk_size" { variable "ssh_keys" { type = string } + +variable "vm_tags" { + type = list +} From 1684328d45dc14e994365e1940aa11311a1d205c Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Fri, 1 Jul 2022 19:12:50 +0200 Subject: [PATCH 4/6] edit Readme to use full Markdown syntax Signed-off-by: GnomeZworc --- README.md | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6043910..68473dc 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,30 @@ +# Tsunami + **Netbox + XO + Terraform + Ansible = The best deployment kit** -How to run:
-cp passwd.auto.tfvars.example passwd.auto.tfvars
-replace all variable to match your infrastructure +## Configuration -edit cloud_network_config.tftpl to replace eth0 (to be changed) +replace your variables: +```bash +# copy password template +cp passwd.auto.tfvars.example passwd.auto.tfvars -create a prefix with IP you want to use on netbox
-edit variables.auto.tfvars +# edit with your infra passwords +nano passwd.auto.tfvars + +# set your template vm network interface +nano cloud_network_config.tftpl + +# create a prefix with IP you want to use on netbox, and set your vm variables +nano variables.auto.tfvars +``` You can add your playbook in the folder playbooks/ and use them in variables.auto.tfvars -then +## Run -terraform init
-terraform plan
+```bash +terraform init +terraform plan terraform apply +``` From e7b507f566d58e33b4d9c3145b26c93681c00125 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Fri, 1 Jul 2022 19:24:22 +0200 Subject: [PATCH 5/6] Add terraform installation link Signed-off-by: GnomeZworc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 68473dc..aae214a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ ## Configuration +[Install terraform](https://www.terraform.io/downloads) + replace your variables: ```bash # copy password template From a5bf5ac889371fbe1d4a4df5bd87a7ba91336935 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Fri, 1 Jul 2022 19:31:17 +0200 Subject: [PATCH 6/6] add condition to execut playbook Signed-off-by: GnomeZworc --- main.tf | 6 ++++++ var.tf | 2 ++ 2 files changed, 8 insertions(+) diff --git a/main.tf b/main.tf index bca776c..bdf4094 100644 --- a/main.tf +++ b/main.tf @@ -69,6 +69,8 @@ resource "xenorchestra_vm" "vm_deployed" { # Generate inventory file resource "local_file" "inventory" { + count = var.playbook != "" ? 1 : 0 + filename = "inventory" content = <