Skip to content

Instantly share code, notes, and snippets.

@qrtt1
Last active December 23, 2015 16:37
Show Gist options
  • Save qrtt1/0c32a30ac3409a4382f5 to your computer and use it in GitHub Desktop.
Save qrtt1/0c32a30ac3409a4382f5 to your computer and use it in GitHub Desktop.
update hosts file by Ansible
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
# variables reflection by setup module
{{nat_ip_address}} {{ansible_fqdn}} {{ansible_hostname}}
# other IP Mappings
[servers]
127.0.0.1 ansible_connection=local
- hosts: servers
vars:
- nat_ip_address: "{{ansible_all_ipv4_addresses[0]}}"
tasks:
- name: generate /etc/hosts
template: src=hosts.j2 dest=/etc/hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment