Last active
December 23, 2015 16:37
-
-
Save qrtt1/0c32a30ac3409a4382f5 to your computer and use it in GitHub Desktop.
update hosts file by Ansible
This file contains hidden or 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
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 |
This file contains hidden or 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
[servers] | |
127.0.0.1 ansible_connection=local |
This file contains hidden or 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: 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