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:
|
||||
|
|
2
inventory/host_vars/geopoiesis/vars.yml
Normal file
2
inventory/host_vars/geopoiesis/vars.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
ansible_become_password: "{{ vault_root_pass }}"
|
||||
ansible_host: "{{ vault_ansible_host }}"
|
|
@ -14,3 +14,4 @@ pylint==2.17.5
|
|||
python-vagrant==1.0.0
|
||||
yamllint==1.32.0
|
||||
jq==1.7.0
|
||||
dnspython==2.6.1
|
||||
|
|
Loading…
Add table
Reference in a new issue