move /etc/hosts configuration in 'preinstall' role
parent
9156d1ecfd
commit
a5094f2a6a
|
@ -1,33 +1,4 @@
|
||||||
---
|
---
|
||||||
- name: populate inventory into hosts file
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/hosts
|
|
||||||
regexp: "^{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}$"
|
|
||||||
line: "{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}"
|
|
||||||
state: present
|
|
||||||
backup: yes
|
|
||||||
when: hostvars[item].ansible_default_ipv4.address is defined
|
|
||||||
with_items: groups['all']
|
|
||||||
|
|
||||||
- name: populate kubernetes loadbalancer address into hosts file
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/hosts
|
|
||||||
regexp: ".*{{ apiserver_loadbalancer_domain_name }}$"
|
|
||||||
line: "{{ loadbalancer_apiserver.address }} lb-apiserver.kubernetes.local"
|
|
||||||
state: present
|
|
||||||
backup: yes
|
|
||||||
when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined
|
|
||||||
|
|
||||||
- name: clean hosts file
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/hosts
|
|
||||||
regexp: "{{ item }}"
|
|
||||||
state: absent
|
|
||||||
backup: yes
|
|
||||||
with_items:
|
|
||||||
- '^127\.0\.0\.1(\s+){{ inventory_hostname }}.*'
|
|
||||||
- '^::1(\s+){{ inventory_hostname }}.*'
|
|
||||||
|
|
||||||
- name: ensure dnsmasq.d directory exists
|
- name: ensure dnsmasq.d directory exists
|
||||||
file:
|
file:
|
||||||
path: /etc/dnsmasq.d
|
path: /etc/dnsmasq.d
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
- name: Hosts | populate inventory into hosts file
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
regexp: "^{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}$"
|
||||||
|
line: "{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}"
|
||||||
|
state: present
|
||||||
|
backup: yes
|
||||||
|
when: hostvars[item].ansible_default_ipv4.address is defined
|
||||||
|
with_items: groups['all']
|
||||||
|
|
||||||
|
- name: Hosts | populate kubernetes loadbalancer address into hosts file
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
regexp: ".*{{ apiserver_loadbalancer_domain_name }}$"
|
||||||
|
line: "{{ loadbalancer_apiserver.address }} {{ apiserver_loadbalancer_domain_name| default('lb-apiserver.kubernetes.local') }}"
|
||||||
|
state: present
|
||||||
|
backup: yes
|
||||||
|
when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined
|
||||||
|
|
||||||
|
- name: Hosts | localhost ipv4 in hosts file
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
line: "127.0.0.1 localhost localhost.localdomain"
|
||||||
|
regexp: '^127.0.0.1.*$'
|
||||||
|
state: present
|
||||||
|
backup: yes
|
||||||
|
|
||||||
|
- name: Hosts | localhost ipv6 in hosts file
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
line: "::1 localhost6 localhost6.localdomain"
|
||||||
|
regexp: '^::1.*$'
|
||||||
|
state: present
|
||||||
|
backup: yes
|
|
@ -51,5 +51,7 @@
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_os_family == "RedHat"
|
||||||
changed_when: False
|
changed_when: False
|
||||||
|
|
||||||
|
- include: etchosts.yml
|
||||||
|
|
||||||
- include: python-bootstrap.yml
|
- include: python-bootstrap.yml
|
||||||
when: ansible_os_family not in [ "Debian", "RedHat" ]
|
when: ansible_os_family not in [ "Debian", "RedHat" ]
|
||||||
|
|
Loading…
Reference in New Issue