Extend /etc/hosts fixup playbook for the loopback IP

On Vagrant in particular, we get an entry for 127.0.0.1 for the server's hostname.
This will cause rabbitmq checks to fail, blocking upgrades.
This commit is contained in:
Mark Goddard 2017-11-22 17:01:30 +00:00
parent 6a6186f64f
commit 92d70e70eb

View File

@ -10,15 +10,18 @@
- name: Ensure overcloud hosts' /etc/hosts does not contain provisioning network IP - name: Ensure overcloud hosts' /etc/hosts does not contain provisioning network IP
hosts: overcloud hosts: overcloud
tasks: tasks:
- name: Ensure overcloud hosts' /etc/hosts does not contain provisioning network IP - name: Ensure overcloud hosts' /etc/hosts does not contain provisioning network or loopback IPs
lineinfile: lineinfile:
dest: /etc/hosts dest: /etc/hosts
regexp: "^{{ provision_oc_net_name | net_ip }}[ \t]*{{ inventory_hostname }}" regexp: "^{{ item }}[ \t]*{{ inventory_hostname }}"
state: absent state: absent
with_items:
- "127.0.0.1"
- "{{ provision_oc_net_name | net_ip }}"
when: provision_oc_net_name | net_ip != None when: provision_oc_net_name | net_ip != None
become: True become: True
- name: Ensure rabbitmq containers' /etc/hosts does not contain provisioning network IP - name: Ensure rabbitmq containers' /etc/hosts does not contain provisioning network or loopback IPs
hosts: overcloud hosts: overcloud
vars: vars:
rabbitmq_containers: rabbitmq_containers:
@ -33,19 +36,22 @@
with_items: "{{ rabbitmq_containers }}" with_items: "{{ rabbitmq_containers }}"
register: ps_result register: ps_result
- name: Ensure rabbitmq containers' /etc/hosts does not contain provisioning network IP - name: Ensure rabbitmq containers' /etc/hosts does not contain provisioning network or loopback IPs
command: > command: >
docker exec -u root {{ item.item }} docker exec -u root {{ item.0.item }}
bash -c bash -c
'cp /etc/hosts /tmp/hosts && 'cp /etc/hosts /tmp/hosts &&
sed -i -e "/^{{ provision_oc_net_name | net_ip }}[ \t]*{{ inventory_hostname }}/d" /tmp/hosts && sed -i -e "/^{{ item.1 }}[ \t]*{{ inventory_hostname }}/d" /tmp/hosts &&
if ! diff -q /tmp/hosts /etc/hosts >/dev/null; then if ! diff -q /tmp/hosts /etc/hosts >/dev/null; then
cp /tmp/hosts /etc/hosts && cp /tmp/hosts /etc/hosts &&
echo changed echo changed
fi && fi &&
rm /tmp/hosts' rm /tmp/hosts'
changed_when: "'changed' in sed_result.stdout" changed_when: "'changed' in sed_result.stdout"
with_items: "{{ ps_result.results }}" with_nested:
when: item.rc == 0 - "{{ ps_result.results }}"
- - "127.0.0.1"
- "{{ provision_oc_net_name | net_ip }}"
when: item.0.rc == 0
register: sed_result register: sed_result
when: provision_oc_net_name | net_ip != None when: provision_oc_net_name | net_ip != None