playbook to update etc/hosts file
This commit is contained in:
parent
49e3125aad
commit
063afb9e11
1 changed files with 17 additions and 0 deletions
17
update_host_file.yml
Normal file
17
update_host_file.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
- hosts:
|
||||
- OSEv3
|
||||
- localhost
|
||||
become: true
|
||||
tasks:
|
||||
- name: debug hostvars for OSEv3 group
|
||||
debug:
|
||||
var: "{{ hostvars }}"
|
||||
verbosity: 3
|
||||
- name: Update /etc/hosts file with all nodes
|
||||
blockinfile:
|
||||
path: /etc/hosts
|
||||
block: |
|
||||
{% for item in groups['OSEv3'] %}
|
||||
{{ hostvars[item]['ansible_default_ipv4']['address'] }} {{ item }}
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in a new issue