Merge "Generate full /etc/hosts on every node"
This commit is contained in:
commit
bac19675ed
@ -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
|
||||
when: customize_etc_hosts | bool == True
|
||||
|
||||
- name: Remove all previous kolla-ansible hosts entries to prevent cruft
|
||||
lineinfile:
|
||||
dest=/etc/hosts
|
||||
regexp="{{ '#' }}a_kolla-ansible_host"
|
||||
state=absent
|
||||
become: True
|
||||
when: customize_etc_hosts | bool == True
|
||||
|
||||
- name: Insert a comment after EOF to put our entries under, IF it is not already present
|
||||
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: Generate etc/hosts
|
||||
blockinfile:
|
||||
dest: /etc/hosts
|
||||
marker: "# {mark} ANSIBLE GENERATED HOSTS"
|
||||
block: |
|
||||
{% for host in groups['all'] %}
|
||||
{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }} {{ hostvars[host]['ansible_hostname'] }}
|
||||
{% endfor %}
|
||||
when: customize_etc_hosts | bool
|
||||
|
||||
- name: ensure sudo group is present
|
||||
group: name=sudo state=present
|
||||
|
Loading…
Reference in New Issue
Block a user