feat(provisioner): add variable that contains hostnames and DNS IP of registered provisioners in provisioner_facts
This commit is contained in:
parent
679518872e
commit
332e367c3c
3 changed files with 10 additions and 2 deletions
|
@ -3,10 +3,15 @@
|
|||
block:
|
||||
- name: save current provisioner hostname
|
||||
ansible.builtin.set_fact:
|
||||
provisioner_hostname: '{{ lookup("pipe", "hostname") }}'
|
||||
provisioner_hostname: '{{ lookup("ansible.builtin.pipe", "hostname") }}'
|
||||
- name: retrieve hostnames and IP addresses of all provisioners
|
||||
ansible.builtin.set_fact:
|
||||
provisioner_controllers_list:
|
||||
'{{ provisioner_controllers_list | default({}) | combine({hostvars[item]["ansible_host"]: lookup("community.general.dig", hostvars[item]["ansible_host"])}) }}'
|
||||
loop: '{{ groups["provisioner"] }}'
|
||||
- name: retrieve provisioner inventory facts
|
||||
ansible.builtin.set_fact:
|
||||
provisioner_facts: '{{ dict(hostvars[provisioner_hostname]) | moreati.jq.jq(JSON_MATCH_QUERY) }}'
|
||||
provisioner_facts: '{{ dict(hostvars[provisioner_hostname]) | combine({"provisioner_controllers_list": provisioner_controllers_list}) | moreati.jq.jq(JSON_MATCH_QUERY) }}'
|
||||
when: inventory_hostname == ansible_play_hosts_all[0]
|
||||
run_once: true
|
||||
vars:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue