kolla-ansible/ansible/roles/baremetal/tasks/append_to_etc_hosts.yml
Sean Mooney 7f1084808b replace baremetal_nic with api_interface
- The baremetal_nic variable was used as part of
  kolla host playbook when generating the /etc/hosts file.
  Populating the /etc/hosts is done to ensure that rabbitmq
  can reach the other nodes in the rabbitmq cluster by hostname.
- Before this change the baremetal_nic variable was used to
  determin which interface to read when mapping the hostname to
  an ip address.
- This change removes baremetal_nic and uses api_interface
  instead as the hostname used by rabbitmq should always map to the
  api_interface ip.

TrivialFix
Closes-Bug: #1618381

Change-Id: I65fe3aad58ac34b001a1f4a38641addc9fa5a1d4
2016-08-31 19:39:59 +00:00

18 lines
620 B
YAML

---
- 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