Merge "Interface for Ansible Host variables"

This commit is contained in:
Zuul 2019-06-18 20:37:00 +00:00 committed by Gerrit Code Review
commit 0e01a81d70
3 changed files with 44 additions and 0 deletions

View File

@ -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 %}

View File

@ -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]}

View File

@ -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]}