Merge pull request #486 from kubespray/etchosts
switch /etc/hosts to use blockinfile
This commit is contained in:
commit
bc8bba5b6b
1 changed files with 6 additions and 5 deletions
|
@ -1,14 +1,15 @@
|
||||||
---
|
---
|
||||||
- name: Hosts | populate inventory into hosts file
|
- name: Hosts | populate inventory into hosts file
|
||||||
lineinfile:
|
blockinfile:
|
||||||
dest: /etc/hosts
|
dest: /etc/hosts
|
||||||
regexp: "^{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address)) }} {{ item }}$"
|
block: |-
|
||||||
line: "{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address)) }} {{ item }}"
|
{% for item in groups['all'] -%}
|
||||||
|
{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address)) }} {{ item }}
|
||||||
|
{% endfor %}
|
||||||
state: present
|
state: present
|
||||||
create: yes
|
create: yes
|
||||||
backup: yes
|
backup: yes
|
||||||
when: hostvars[item].ansible_default_ipv4.address is defined
|
marker: "# Ansible inventory hosts {mark}"
|
||||||
with_items: "{{ groups['all'] }}"
|
|
||||||
|
|
||||||
- name: Hosts | populate kubernetes loadbalancer address into hosts file
|
- name: Hosts | populate kubernetes loadbalancer address into hosts file
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
|
Loading…
Reference in a new issue