Generate full /etc/hosts on every node
Since compute nodes needs to resolve each other, and controller nodes needs to resolve each other, let everyone resolve everyone. Change-Id: I1ee117bdb2d71d48a064c4d317b53a1500bdd753 Closes-Bug: #1623669
This commit is contained in:
parent
ad2d6567a6
commit
01d2e2e331
@ -1,17 +0,0 @@
|
|||||||
---
|
|
||||||
- name: get real node hostname
|
|
||||||
shell: echo $(hostname)
|
|
||||||
register: real_node_hostname
|
|
||||||
delegate_to: "{{ control_node }}"
|
|
||||||
|
|
||||||
- name: get real node ip
|
|
||||||
shell: ip -4 addr show "{{ hostvars[control_node]['api_interface'] }}" | grep -oP "(?<=inet )[\d\.]+(?=/)"
|
|
||||||
register: real_node_ip
|
|
||||||
delegate_to: "{{ control_node }}"
|
|
||||||
|
|
||||||
- name: Insert hosts entries for all kolla-ansible hosts
|
|
||||||
lineinfile:
|
|
||||||
dest=/etc/hosts
|
|
||||||
line="{{ real_node_ip.stdout }} {{ real_node_hostname.stdout.split('.')[0] }} {{ real_node_hostname.stdout }} {{ '#' }}a_kolla_ansible_host"
|
|
||||||
insertafter=".*kolla-ansible\ hosts"
|
|
||||||
state=present
|
|
@ -20,30 +20,15 @@
|
|||||||
become: True
|
become: True
|
||||||
when: customize_etc_hosts | bool == True
|
when: customize_etc_hosts | bool == True
|
||||||
|
|
||||||
- name: Remove all previous kolla-ansible hosts entries to prevent cruft
|
- name: Generate etc/hosts
|
||||||
lineinfile:
|
blockinfile:
|
||||||
dest=/etc/hosts
|
dest: /etc/hosts
|
||||||
regexp="{{ '#' }}a_kolla-ansible_host"
|
marker: "# {mark} ANSIBLE GENERATED HOSTS"
|
||||||
state=absent
|
block: |
|
||||||
become: True
|
{% for host in groups['all'] %}
|
||||||
when: customize_etc_hosts | bool == True
|
{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }} {{ hostvars[host]['ansible_hostname'] }}
|
||||||
|
{% endfor %}
|
||||||
- name: Insert a comment after EOF to put our entries under, IF it is not already present
|
when: customize_etc_hosts | bool
|
||||||
lineinfile:
|
|
||||||
dest=/etc/hosts
|
|
||||||
regexp="{{ '#' }}kolla-ansible hosts"
|
|
||||||
line="{{ '#' }}kolla-ansible hosts"
|
|
||||||
insertafter=EOF
|
|
||||||
state=present
|
|
||||||
become: True
|
|
||||||
when: customize_etc_hosts | bool == True
|
|
||||||
|
|
||||||
- include: append_to_etc_hosts.yml
|
|
||||||
with_inventory_hostnames: control
|
|
||||||
loop_control:
|
|
||||||
loop_var: control_node
|
|
||||||
become: True
|
|
||||||
when: customize_etc_hosts | bool == True
|
|
||||||
|
|
||||||
- name: ensure sudo group is present
|
- name: ensure sudo group is present
|
||||||
group: name=sudo state=present
|
group: name=sudo state=present
|
||||||
|
Loading…
Reference in New Issue
Block a user