From b865b23baff2d5c9aa1c5f3fe8e079b0919c2474 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 21 Sep 2024 18:24:47 +0200 Subject: [PATCH] Separazione del playbook deploy (obbligatorio) e addizionali. --- vm-ansible/__main__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vm-ansible/__main__.py b/vm-ansible/__main__.py index e829261..ea7ccb7 100644 --- a/vm-ansible/__main__.py +++ b/vm-ansible/__main__.py @@ -75,12 +75,18 @@ inventory = command.local.Command("a-inventory", opts = pulumi.ResourceOptions(depends_on = [ wait_time ]) ) -# Applying the command -for playbook in config.get('playbooks').split(','): - execute_ansible = command.local.Command(f"a-{playbook.split('.')[0]}", +deploy = command.local.Command('ap deploy', + create = 'ansible-playbook deploy.yml', + delete = 'rm -f ./ansible.log', + opts = pulumi.ResourceOptions(depends_on = [ inventory ]) +) + +# Running additional playbooks +for playbook in sorted(config.get('playbooks').split(',')): + execute_ansible = command.local.Command(f"ap {playbook.split('.')[0]}", create = f"ansible-playbook {playbook}", delete = "rm -f ./ansible.log", - opts = pulumi.ResourceOptions(depends_on = [ inventory ]) + opts = pulumi.ResourceOptions(depends_on = [ deploy ]) ) pulumi.export("ip", vm.network_interfaces[0]['addresses'][0])