From 17e16e5107781c3ebeeb726f906ccfa24dad6b7a Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 7 Jun 2019 16:01:29 -0400 Subject: [PATCH] Interface for Ansible Host variables The new AnsibleHostVarsMap output is a map of roles to Ansible host vars, which later will be in config-download and populate the Ansible host vars for each host in each role. Change-Id: I3880f0f72beb24ee0b0868dca48afce6328144d3 --- common/deploy-steps.j2 | 3 +++ overcloud.j2.yaml | 15 +++++++++++++++ puppet/role.role.j2.yaml | 26 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 2ba5e704f9..7f1445143f 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -156,6 +156,9 @@ parameters: default: '' type: string description: A string of entries to be added to /etc/hosts on each node. + AnsibleHostVarsMap: + type: json + default: {} conditions: {% for role in enabled_roles %} diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index ffaefdcb7a..5b394b89e1 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -979,6 +979,18 @@ resources: - {get_attr: [{{role.name}}, blacklist_ip_address]} {%- endfor %} + AnsibleHostVars: + type: OS::Heat::Value + properties: + type: json + value: +{%- for role in roles %} + {{role.name}}: + map_merge: + list_concat: + - {get_attr: [{{role.name}}, ansible_host_vars_map]} +{%- endfor %} + BlacklistedHostnames: type: OS::Heat::Value properties: @@ -1187,3 +1199,6 @@ outputs: {%- for role in roles %} - {get_attr: [{{role.name}}, hostname_network_config_map]} {%- endfor %} + AnsibleHostVarsMap: + description: Map of Ansible Host variables per role + value: {get_attr: [AnsibleHostVars, value]} diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml index 34479b9b45..eae5a21134 100644 --- a/puppet/role.role.j2.yaml +++ b/puppet/role.role.j2.yaml @@ -802,7 +802,33 @@ resources: CTLPLANEIP: {get_attr: [{{server_resource_name}}, networks, ctlplane, 0]} CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]} + {{server_resource_name}}AnsibleHostVars: + type: OS::Heat::Value + properties: + type: json + value: + # These variables aren't used anywhere yet but it's a base so later we can use it to + # build the per-host hieradata. + {%- for network in networks %} + {%- if network.enabled|default(true) and network.name in role.networks|default([]) %} + fqdn_{{network.name_lower}}: {get_attr: [NetHostMap, value, {{network.name_lower}}, fqdn]} + {%- endif %} + {%- endfor %} + fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]} + fqdn_canonical: {get_attr: [NetHostMap, value, canonical, fqdn]} + + outputs: + ansible_host_vars_map: + description: | + Map of Ansible variables specific per host. + This map is used to construct the AnsibleHostVarsMap output for the + ansible vars per host in config-download. + value: + map_replace: + - host: {get_attr: [{{server_resource_name}}AnsibleHostVars, value]} + - keys: + host: {get_attr: [{{server_resource_name}}, name]} ip_address: description: IP address of the server in the ctlplane network value: {get_attr: [{{server_resource_name}}, networks, ctlplane, 0]}