Created
October 9, 2020 22:32
-
-
Save csmart/417e4d66ad790037b5588e2e3040c4a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
gather_facts: yes | |
tasks: | |
- name: Update /etc/hosts to resolve other hosts in inventory | |
blockinfile: | |
path: /etc/hosts | |
state: present | |
marker: "# {mark} {{ hostvars[item]['inventory_hostname'] }} managed by Ansible task" | |
block: |- | |
{{ hostvars[item]['ansible_default_ipv4']['address'] }} {{ hostvars[item]['inventory_hostname'] }} | |
become: true | |
with_items: "{{ play_hosts }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment