Created
April 28, 2016 12:07
-
-
Save alfredodeza/5104d34ea88f910482116a531578c290 to your computer and use it in GitHub Desktop.
ensure that the current `hostname` is defined in `/etc/hosts`
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
--- | |
# Because not everything is correct in this world, we may end up with a host that doesn't have the reported | |
# hostname in the hosts file. | |
- name: ensure that the current host is in /etc/hosts. Yes this is a thing. | |
sudo: true | |
replace: | |
backup: yes | |
dest: /etc/hosts | |
regexp: '^(127\.0\.1\.1(?!.*\b{{ ansible_hostname }}\b).*)$' | |
replace: '\1 {{ ansible_hostname }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment