Final fixing with tests.
This commit is contained in:
parent
64b5aafcbd
commit
705ac0fc0a
@ -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.
|
# 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.
|
# Creating the inventory file (which will not be used by pulumi for ansible,
|
||||||
with open('inventory', 'w') as f:
|
# btw).
|
||||||
vm.ipv4_addresses[1][0].apply(
|
inventory = open('inventory', 'w')
|
||||||
lambda lanip: f.write(f"{vm_name} ansible_host={lanip} ansible_user={vm_username}")
|
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
|
# Try the deployment with ansible
|
||||||
|
|
||||||
# Applying the command
|
# Applying the command
|
||||||
execute_ansible = command.local.Command("ansible",
|
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])
|
opts = pulumi.ResourceOptions(depends_on = [vm])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,3 +3,4 @@ collections_on_ansible_version_mismatch = ignore
|
|||||||
action_warnings = False
|
action_warnings = False
|
||||||
host_key_checking = False
|
host_key_checking = False
|
||||||
inventory = inventory
|
inventory = inventory
|
||||||
|
log_path = ./ansible.log
|
||||||
|
Loading…
Reference in New Issue
Block a user