parent
9c7e889c3e
commit
1a9085ed1a
@ -0,0 +1,27 @@ |
|||||||
|
--- |
||||||
|
- name: Detect domain name |
||||||
|
set_fact: |
||||||
|
domainname: "{{ ansible_dns.domain|default(False) or ansible_dns.search.0|default(False) or ansible_domain|default(False) or 'invalid'}}" |
||||||
|
|
||||||
|
- name: Add name/IP to hosts file |
||||||
|
lineinfile: |
||||||
|
dest: /etc/hosts |
||||||
|
regexp: '^{{ ansible_default_ipv4.address }}' |
||||||
|
line: '{{ ansible_default_ipv4.address }} {{ ansible_hostname }}.{{ domainname }} {{ ansible_hostname }}' |
||||||
|
backup: yes |
||||||
|
|
||||||
|
- name: Clean/remove 127.0.1.1 |
||||||
|
lineinfile: |
||||||
|
dest: /etc/hosts |
||||||
|
regexp: '^127.0.1.1' |
||||||
|
state: absent |
||||||
|
backup: yes |
||||||
|
|
||||||
|
- name: Ensure 127.0.0.1 localhost |
||||||
|
lineinfile: |
||||||
|
dest: /etc/hosts |
||||||
|
regexp: '127.0.0.1' |
||||||
|
line: '127.0.0.1 localhost localhost.localdomain' |
||||||
|
insertbefore: BOF |
||||||
|
backup: yes |
||||||
|
|
||||||
Loading…
Reference in new issue