From 5c530292320c1664453e83de529dc26ca317a06f Mon Sep 17 00:00:00 2001 From: James Slagle Date: Fri, 12 Jul 2019 12:27:32 -0400 Subject: [PATCH] Set HieradataVars as group vars instead Instead of writing a set of vars to hieradata_vars.yaml and then passing that into tasks with vars_files, just set the data as group vars. This makes for a simpler interface without having to remember to pass in the data with vars_files on any task/play that might require them. Change-Id: I851d9404861d55791bde1346c58bc1c94f591569 --- common/deploy-steps.j2 | 6 ------ overcloud.j2.yaml | 35 ---------------------------------- puppet/role.role.j2.yaml | 41 +++++++++++++++++++++++++++++++++------- 3 files changed, 34 insertions(+), 48 deletions(-) diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 0814071da4..e8ea9cb768 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -119,9 +119,6 @@ parameters: {{role.name}}DeploymentHierarchy: type: json default: {} - {{role.name}}HieradataVars: - type: json - default: {} {%- endfor %} ValidateControllersIcmp: default: true @@ -515,8 +512,6 @@ outputs: - hosts: {{primary_role_name}}:DEPLOY_TARGET_HOST name: Server hieradata from vars gather_facts: {{ '"{{' }} gather_facts | default(false) {{ '}}"' }} - vars_files: - - {{role.name}}/hieradata_vars.yaml tasks: - name: Hieradata from vars include_role: @@ -796,7 +791,6 @@ outputs: {%- for role in roles %} {{role.name}}/deployment-hieradata.j2.yaml: {get_param: {{role.name}}DeploymentHieradata} {{role.name}}/deployment-hierarchy.yaml: {get_param: {{role.name}}DeploymentHierarchy} - {{role.name}}/hieradata_vars: {get_param: {{role.name}}HieradataVars} {%- endfor %} update_steps_tasks: | {%- for role in roles %} diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index 9d9f7fe90e..4c1a73ef28 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -734,38 +734,6 @@ resources: {%- endfor %} cloud_name_ctlplane: {get_param: CloudNameCtlplane} -{%- for outer_role in roles %} - - {{outer_role.name}}HieradataVars: - type: OS::Heat::Value - properties: - value: - bootstrap_nodeid: - yaql: - expression: coalesce($.data, []).first(null) - data: {get_attr: [{{outer_role.name}}, hostname]} - ctlplane_subnet_cidr: - if: - - ctlplane_subnet_cidr_set - - {get_param: ControlPlaneSubnetCidr} - - {str_split: ['/', {get_attr: [ControlVirtualIP, subnets, 0, cidr]}, 1]} - network_cidrs: - {%- for network in networks %} - {%- if network.enabled|default(true) and network.name in outer_role.networks|default([]) %} - {{network.name}}_cidr: - yaql: - expression: switch(isList($.data) and $.data.len() > 0 => $.data[0], true => "") - data: {get_attr: [{{outer_role.name}}, {{network.name}}_cidr]} - {%- endif %} - {%- endfor %} - role_networks: - {%- for network in networks %} - {%- if network.enabled|default(true) and network.name in outer_role.networks|default([]) %} - - {{network.name}} - {% endif %} - {% endfor %} -{%- endfor %} - GlobalConfig: type: OS::Heat::Value properties: @@ -1014,9 +982,6 @@ resources: {%- endfor %} {%- endfor %} HostsEntry: {get_attr: [HostsEntryValue, value]} -{%- for role in roles %} - {{role.name}}HieradataVars: {get_attr: [{{role.name}}HieradataVars, value]} -{%- endfor %} EnabledServices: list_concat: {%- for role in roles %} diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml index 5b3a50168f..84b63fd803 100644 --- a/puppet/role.role.j2.yaml +++ b/puppet/role.role.j2.yaml @@ -710,6 +710,31 @@ resources: fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]} fqdn_canonical: {get_attr: [NetHostMap, value, canonical, fqdn]} + {{server_resource_name}}GroupVars: + type: OS::Heat::Value + properties: + value: + bootstrap_nodeid: {get_attr: [{{server_resource_name}}, name]} + ctlplane_subnet_cidr: + if: + - ctlplane_subnet_cidr_set + - {get_param: ControlPlaneSubnetCidr} + - yaql: + expression: str("{0}".format($.data).split("/")[-1]) + data: {get_attr: [{{server_resource_name}}, addresses, ctlplane, 0, subnets, 0, cidr]} + network_cidrs: + {%- for network in networks %} + {%- if network.enabled|default(true) and network.name in role.networks|default([]) %} + {{network.name}}_cidr: {get_attr: [{{network.name}}Port, cidr]} + {%- endif %} + {%- endfor %} + role_networks: + {%- for network in networks %} + {%- if network.enabled|default(true) and network.name in role.networks|default([]) %} + - {{network.name}} + {% endif %} + {% endfor %} + outputs: ansible_host_vars_map: @@ -818,17 +843,19 @@ outputs: {%- endfor %} role_group_vars: value: - any_errors_fatal: {get_param: {{role.name}}AnyErrorsFatal} - max_fail_percentage: {get_param: {{role.name}}MaxFailPercentage} - neutron_physical_bridge_name: {get_param: NeutronPhysicalBridge} - neutron_public_interface_name: {get_param: NeutronPublicInterface} - network_deployment_actions: {get_attr: [NetworkDeploymentActionsValue, value]} - role_networks: + map_merge: + - any_errors_fatal: {get_param: {{role.name}}AnyErrorsFatal} + max_fail_percentage: {get_param: {{role.name}}MaxFailPercentage} + neutron_physical_bridge_name: {get_param: NeutronPhysicalBridge} + neutron_public_interface_name: {get_param: NeutronPublicInterface} + network_deployment_actions: {get_attr: [NetworkDeploymentActionsValue, value]} + role_networks: {%- for network in networks %} {%- if network.enabled|default(true) and network.name in role.networks|default([]) %} - - {{network.name}} + - {{network.name}} {%- endif %} {%- endfor %} + - {get_attr: [{{server_resource_name}}GroupVars, value]} {%- for network in networks %} {%- if network.enabled|default(true) and network.name in role.networks|default([]) %} {{network.name}}_cidr: