diff --git a/playbook.yml b/playbook.yml index 45e2822..b58690e 100644 --- a/playbook.yml +++ b/playbook.yml @@ -51,9 +51,15 @@ delay: 100 until: job_poll.finished + - name: Parse results into dictionary + ansible.builtin.set_fact: + nodes: "{{ nodes | default([]) + [ {'name': item.instance.hw_name, 'ip': item.item.item.ip | ansible.utils.ipaddr('address')} ] }}" + with_items: "{{ job_poll | json_query('results[*]') }}" + no_log: true + - name: Register new VM's in inventory ansible.builtin.add_host: - name: "{{ item.instance.hw_name }}" - ansible_host: "{{ item.item.item.ip | ansible.utils.ipaddr('address') }}" - groups: k3s-ha - with_items: "{{ job_poll | json_query('results[*]') }}" + name: "{{ item.name }}" + ansible_host: "{{ item.ip }}" + groups: k3s_ha + with_items: "{{ nodes }}"