Generate 127.0.1.1 entry on each individual host

The hostfile update script is currently being generated on the
deployment host and copied to all other hosts within an environment.
This is resulting in the 127.0.1.1 entry always containing the hostname
of the deployment host.

Instead, generate a temporary file for the script locally which
pre-populates all shared hosts entries and use that as a template for
assigning the 127.0.1.1 entry on each remote host.

Change-Id: Ia5e375772cab76c748cca058ae7d7944e7528020
Closes-Bug: #1657568
This commit is contained in:
Jimmy McCrory 2017-01-25 15:02:58 -08:00
parent 7af8e1599a
commit a436640aa7
2 changed files with 3 additions and 1 deletions

View File

@ -22,7 +22,7 @@
run_once: true
- name: Copy templated hosts file entries script
copy:
template:
src: "/var/tmp/openstack-host-hostfile-setup.sh"
dest: "/usr/local/bin/openstack-host-hostfile-setup.sh"
mode: "0755"

View File

@ -34,12 +34,14 @@ function host_update {
fi
}
{% raw -%}
{% set host_rfc_1034_1035_name = inventory_hostname|replace('_', '-') %}
host_update "{{ ansible_hostname|default(host_rfc_1034_1035_name) }}" \
"{{ host_rfc_1034_1035_name }}" \
"{{ inventory_hostname }}" \
"127.0.1.1" \
"{{ openstack_domain }}"
{% endraw %}
{% for item in groups['all'] %}
{% set target_rfc_1034_1035_name = item|replace('_', '-') %}