Separazione del playbook deploy (obbligatorio) e addizionali.

This commit is contained in:
Emiliano Vavassori 2024-09-21 18:24:47 +02:00
parent 7a81d01461
commit b865b23baf

View File

@ -75,12 +75,18 @@ inventory = command.local.Command("a-inventory",
opts = pulumi.ResourceOptions(depends_on = [ wait_time ]) opts = pulumi.ResourceOptions(depends_on = [ wait_time ])
) )
# Applying the command deploy = command.local.Command('ap deploy',
for playbook in config.get('playbooks').split(','): create = 'ansible-playbook deploy.yml',
execute_ansible = command.local.Command(f"a-{playbook.split('.')[0]}", delete = 'rm -f ./ansible.log',
create = f"ansible-playbook {playbook}",
delete = "rm -f ./ansible.log",
opts = pulumi.ResourceOptions(depends_on = [ inventory ]) 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 = [ deploy ])
)
pulumi.export("ip", vm.network_interfaces[0]['addresses'][0]) pulumi.export("ip", vm.network_interfaces[0]['addresses'][0])