You've already forked ansible-role-common
Attempt to make the Hosts file setup non-breaking. e.g not wipe out custom entries
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
enabled: yes
|
||||
tags: ntp
|
||||
|
||||
- name: Ensure Hostname/DNS common config
|
||||
- name: Ensure DNS and SSH common config
|
||||
template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
@@ -64,10 +64,10 @@
|
||||
dest: /etc/sysconfig/network,
|
||||
mode: o+rw
|
||||
}
|
||||
- { src: etc.hosts.j2,
|
||||
dest: /etc/hosts,
|
||||
mode: o=rw,g=r,a=r
|
||||
}
|
||||
#- { src: etc.hosts.j2,
|
||||
# dest: /etc/hosts,
|
||||
# mode: o=rw,g=r,a=r
|
||||
# }
|
||||
- { src: etc.resolv.conf.j2,
|
||||
dest: /etc/resolv.conf,
|
||||
mode: o=rw,g=r,a=r
|
||||
@@ -80,7 +80,23 @@
|
||||
- Restart NTPD
|
||||
- Restart SSH
|
||||
tags: dns
|
||||
|
||||
|
||||
- name: Ensure hosts file correct
|
||||
lineinfile:
|
||||
dest: /etc/hosts
|
||||
regexp: "^127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4"
|
||||
line: "127.0.0.1 localhost {{ ansible_hostname }}"
|
||||
with_items:
|
||||
- {regexp: "^127.0.0.1 localhost.+",
|
||||
line: "127.0.0.1 localhost {{ ansible_hostname }}"
|
||||
}
|
||||
- {regexp: "^::1.+",
|
||||
line: "::1 localhost {{ ansible_hostname }}"
|
||||
}
|
||||
- {regexp: "^{{ ansible_default_ipv4.address }}.+{{ ansible_default_ipv4.address.split('.')[-1] }}$",
|
||||
line: "{{ ansible_default_ipv4.address }} {{ ansible_hostname }}.{{ domain }} {{ ansible_hostname }}"
|
||||
}
|
||||
|
||||
- name: Ensure correct permissions (hosts/resolv.conf)
|
||||
file:
|
||||
path: "{{item}}"
|
||||
|
||||
Reference in New Issue
Block a user