add condition to execut playbook
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
e7b507f566
commit
a5bf5ac889
6
main.tf
6
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 = <<EOF
|
||||
[all]
|
||||
|
@ -77,12 +79,16 @@ EOF
|
|||
}
|
||||
|
||||
resource "time_sleep" "wait_30_seconds" {
|
||||
count = var.playbook != "" ? 1 : 0
|
||||
|
||||
depends_on = [xenorchestra_vm.vm_deployed]
|
||||
|
||||
create_duration = "30s"
|
||||
}
|
||||
|
||||
resource "null_resource" "run-ansible" {
|
||||
count = var.playbook != "" ? 1 : 0
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = "ansible-playbook -D -i inventory playbooks/${var.playbook} "
|
||||
environment = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user