Cleanups
This commit is contained in:
parent
495ce63cdf
commit
b6bf9ebce3
|
@ -1,30 +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
|
- name: Add name/IP to hosts file
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: /etc/hosts
|
dest: /etc/hosts
|
||||||
regexp: '^{{ ansible_default_ipv4.address }}.*{{ ansible_hostname }}\.ansible\.kurs.*{{ ansible_hostname }}'
|
regexp: '^{{ ansible_default_ipv4.address }}'
|
||||||
line: '{{ ansible_default_ipv4.address }} {{ ansible_hostname }}.ansible.kurs {{ ansible_hostname }}'
|
line: '{{ ansible_default_ipv4.address }} {{ ansible_hostname }}.{{ domainname }} {{ ansible_hostname }}'
|
||||||
backup: yes
|
backup: yes
|
||||||
|
|
||||||
- name: Clean/remove 127.0.1.1
|
- name: Clean/remove 127.0.1.1
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: /etc/hosts
|
dest: /etc/hosts
|
||||||
regexp: '127.0.1.1.*{{ ansible_hostname }}'
|
regexp: '^127.0.1.1'
|
||||||
state: absent
|
|
||||||
backup: yes
|
|
||||||
|
|
||||||
- name: Clean/remove 127.0.0.1 ... Hostname
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/hosts
|
|
||||||
regexp: '127.0.0.1.*{{ ansible_hostname }}'
|
|
||||||
state: absent
|
state: absent
|
||||||
backup: yes
|
backup: yes
|
||||||
|
|
||||||
- name: Ensure 127.0.0.1 localhost
|
- name: Ensure 127.0.0.1 localhost
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: /etc/hosts
|
dest: /etc/hosts
|
||||||
regexp: '127.0.0.1.*localhost'
|
regexp: '127.0.0.1'
|
||||||
line: '127.0.0.1 localhost localhost.localdomain # from Ansible'
|
line: '127.0.0.1 localhost localhost.localdomain'
|
||||||
insertbefore: BOF
|
insertbefore: BOF
|
||||||
backup: yes
|
backup: yes
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue