Open binaryArrow opened 2 months ago
When I use the playbook resource and run following task:
playbook
- name: debug debug: msg: "{{ groups['azure_nomad_vms'] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | join(',') }}"
which should give me a list of 3 ip addresses because I have 3 Host machines, it only gives me one. I use the ip's to set the server ip's in a nomad config file. I am using the playbook resource like this:
resource "ansible_playbook" "playbook" { count = var.vm_number playbook = "../ansible/playbook.yml" name = azurerm_public_ip.this[count.index].ip_address replayable = true groups = ["azure_nomad_vms"] extra_vars = { ansible_user = ansible_host.this[count.index].variables.ansible_user ansible_ssh_private_key_file = ansible_host.this[count.index].variables.ansible_ssh_private_key_file ansible_python_interpreter = "/usr/bin/python3" } } output "ansible_playbook_stdout" { value = ansible_playbook.playbook[*].ansible_playbook_stdout }
Using a null_resource with local_exec works, but I would rather prefer using the playbook resource
null_resource
local_exec
When I use the
playbook
resource and run following task:which should give me a list of 3 ip addresses because I have 3 Host machines, it only gives me one. I use the ip's to set the server ip's in a nomad config file. I am using the
playbook
resource like this:Using a
null_resource
withlocal_exec
works, but I would rather prefer using theplaybook
resource