From 3bdf0c980f046a61b652bcfc9ee1798f31abe577 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Tue, 22 Oct 2019 14:31:42 -0400 Subject: [PATCH] Use ansible for hosts entries This patch updates the templates to use the new ansible role, tripleo-hosts-entries, for managing the entries in /etc/hosts instead of the values from the Heat stack. Change-Id: I606e0f27f9f9ae9d85bc0fc653f8985eb734d004 Depends-On: Ia02ca1263590e2b579f2534e99119d7b1cd4b39a (cherry picked from commit 597cdb67962289f35cb37f17a2cd427af6b81358) --- common/deploy-steps.j2 | 31 ++++++++++++++++--- overcloud.j2.yaml | 7 +++++ puppet/role.role.j2.yaml | 1 + ...le-for-hosts-entries-b4905552515e17ff.yaml | 6 ++++ 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/use-ansible-for-hosts-entries-b4905552515e17ff.yaml diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 748f630a2b..c003731af4 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -203,6 +203,21 @@ parameters: default: {} type: json description: Map of extra data (hieradata) to set on each node. + UndercloudHostsEntries: + default: [] + description: > + List of undercloud hosts entries to be appended to /etc/hosts. The + value is populated with the HEAT_HOSTS entries on the undercloud by + tripleoclient when running deploy. + type: comma_delimited_list + ExtraHostsEntries: + default: [] + description: List of extra hosts entries to be appended to /etc/hosts + type: comma_delimited_list + VipHostsEntries: + default: [] + description: List of VIP (virtual IP) hosts entries to be appended to /etc/hosts + type: comma_delimited_list conditions: {% for role in enabled_roles %} @@ -371,6 +386,9 @@ outputs: enable_internal_tls: {get_param: EnableInternalTLS} cloud_domain: {get_param: CloudDomain} all_nodes_extra_map_data: {get_param: AllNodesExtraMapData} + undercloud_hosts_entries: {get_param: UndercloudHostsEntries} + extra_hosts_entries: {get_param: ExtraHostsEntries} + vip_hosts_entries: {get_param: VipHostsEntries} common_deploy_steps_tasks: {get_file: deploy-steps-tasks.yaml} deploy_steps_tasks_step_0: {get_file: deploy-steps-tasks-step-0.yaml} common_deploy_steps_tasks_step_1: {get_file: deploy-steps-tasks-step-1.yaml} @@ -658,10 +676,15 @@ outputs: environment: artifact_urls: {{ '"{{' }} deploy_artifact_urls {{ '}}"' }} - - name: HostsConfig - script: hosts-config.sh - environment: - HOSTS_ENTRY: {{ '"{{' }} hosts_entry {{ '}}"' }} + - name: Configure Hosts Entries + include_role: + name: tripleo-hosts-entries + vars: + tripleo_hosts_entries_undercloud_hosts_entries: {{ '"{{ ' }} undercloud_hosts_entries {{ ' }}"' }} + tripleo_hosts_entries_extra_hosts_entries: {{ '"{{ ' }} extra_hosts_entries {{ ' }}"' }} + tripleo_hosts_entries_vip_hosts_entries: {{ '"{{ ' }} vip_hosts_entries {{ ' }}"' }} + tags: + - tripleo_hosts_entries tags: - overcloud diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index 529df7422a..eef4e17360 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -1121,6 +1121,13 @@ resources: - redis: {get_attr: [RedisVirtualIP, ip_address]} - ovn_dbs: {get_attr: [OVNDBsVirtualIP, ip_address]} CloudNames: {get_attr: [CloudNames, value]} + UndercloudHostsEntries: {get_param: UndercloudHostsEntries} + ExtraHostsEntries: {get_param: ExtraHostFileEntries} + VipHostsEntries: + if: + - add_vips_to_etc_hosts + - {get_attr: [VipHosts, value]} + - '' outputs: ManagedEndpoints: diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml index d154032b94..e42c195c40 100644 --- a/puppet/role.role.j2.yaml +++ b/puppet/role.role.j2.yaml @@ -589,6 +589,7 @@ resources: {%- endfor %} fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]} fqdn_canonical: {get_attr: [NetHostMap, value, canonical, fqdn]} + hostname_resolve_network: {get_param: [ServiceNetMap, {{role.name}}HostnameResolveNetwork]} outputs: ansible_host_vars_map: diff --git a/releasenotes/notes/use-ansible-for-hosts-entries-b4905552515e17ff.yaml b/releasenotes/notes/use-ansible-for-hosts-entries-b4905552515e17ff.yaml new file mode 100644 index 0000000000..8a45deb207 --- /dev/null +++ b/releasenotes/notes/use-ansible-for-hosts-entries-b4905552515e17ff.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + The ansible tripleo-hosts-entries is now used for adding individual entries + to /etc/hosts for each overcloud node. This role is used instead of the + output data from the Heat stack.