Final fixing with tests.

This commit is contained in:
Emiliano Vavassori 2022-08-17 23:05:54 +02:00
parent 64b5aafcbd
commit 705ac0fc0a
2 changed files with 11 additions and 6 deletions

View File

@ -95,17 +95,21 @@ vm = proxmox.vm.VirtualMachine("vm",
# First item of the ipv4_addresses is of the loopback interface (so the usual 127.0.0.1). Let's get the second and grab only the text.
# Creating the inventory file.
with open('inventory', 'w') as f:
vm.ipv4_addresses[1][0].apply(
lambda lanip: f.write(f"{vm_name} ansible_host={lanip} ansible_user={vm_username}")
)
# Creating the inventory file (which will not be used by pulumi for ansible,
# btw).
inventory = open('inventory', 'w')
vm.ipv4_addresses[1][0].apply(
lambda lanip: inventory.write(f"{vm_name} ansible_host={lanip} ansible_user={vm_username}")
)
inventory.close()
# Try the deployment with ansible
# Applying the command
execute_ansible = command.local.Command("ansible",
create = f"ansible-playbook {ansible_playbook}",
create = vm.ipv4_addresses[1][0].apply(
lambda ipaddr: f"ansible-playbook -i '{ipaddr},' {ansible_playbook}"
),
opts = pulumi.ResourceOptions(depends_on = [vm])
)

View File

@ -3,3 +3,4 @@ collections_on_ansible_version_mismatch = ignore
action_warnings = False
host_key_checking = False
inventory = inventory
log_path = ./ansible.log