diff --git a/proxmoxve-ansible-python/__main__.py b/proxmoxve-ansible-python/__main__.py index 4f74cdd..5b00317 100644 --- a/proxmoxve-ansible-python/__main__.py +++ b/proxmoxve-ansible-python/__main__.py @@ -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]) ) diff --git a/proxmoxve-ansible-python/ansible.cfg b/proxmoxve-ansible-python/ansible.cfg index 43406af..767948b 100644 --- a/proxmoxve-ansible-python/ansible.cfg +++ b/proxmoxve-ansible-python/ansible.cfg @@ -3,3 +3,4 @@ collections_on_ansible_version_mismatch = ignore action_warnings = False host_key_checking = False inventory = inventory +log_path = ./ansible.log