From cb767a97b90206b77167682dcffe5fbc1856fff5 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 4 Jun 2019 15:39:33 -0400 Subject: [PATCH] Use Ansible for {{server_resource_name}}Deployment Use the new tripleo-hieradata Ansible role to configure the remaining Hieradata files that were created by Heat before. {{server_resource_name}} isn't yet fully converted to Ansible, and another patch will remove the resource when Ansible controls the hiera.yaml file in /etc/puppet/hieradata. Change-Id: Ib946b566d66300d23e7abc12498cc11d3f5fa5f8 implements: blueprint reduce-deployment-resources --- common/deploy-steps.j2 | 26 +++++++++++- overcloud.j2.yaml | 8 ++++ puppet/role.role.j2.yaml | 91 ++++++++++++++++++++++++---------------- 3 files changed, 87 insertions(+), 38 deletions(-) diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 7f1445143f..ff6b6a2bdd 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -119,6 +119,12 @@ parameters: {{role.name}}AllNodesDeploymentHieradata: type: json default: {} + {{role.name}}DeploymentHieradata: + type: json + default: {} + {{role.name}}PerHostHieradata: + type: json + default: {} {%- endfor %} ValidateControllersIcmp: default: true @@ -400,6 +406,23 @@ outputs: hieradata_variable_start_string: $$ hieradata_variable_end_string: $$ when: tripleo_role_name == '{{role.name}}' + - name: Deployment hieradata + include_role: + name: tripleo-hieradata + vars: + hieradata_template: "{{role.name}}/deployment-hieradata.j2.yaml" + hieradata_variable_start_string: $$ + hieradata_variable_end_string: $$ + when: tripleo_role_name == '{{role.name}}' + - name: Per-host hieradata + include_role: + name: tripleo-hieradata + vars: + hieradata_template: "{{role.name}}/per-host-hieradata.j2.yaml" + hieradata_per_host: True + hieradata_variable_start_string: $$ + hieradata_variable_end_string: $$ + when: tripleo_role_name == '{{role.name}}' {%- endfor %} tags: - overcloud @@ -651,11 +674,12 @@ outputs: external_deploy_steps_tasks: {get_attr: [ExternalDeployTasks, value]} external_post_deploy_steps_tasks: {get_attr: [ExternalPostDeployTasks, value]} {%- for role in roles %} - {{role.name}}/all-nodes-deployment-hieradata.j2: {get_param: {{role.name}}AllNodesDeploymentHieradata} # TODO (slagle): temporarily write the path with a .yaml extension until # https://review.opendev.org/#/c/663736 merges. Once merged, this can be # removed. {{role.name}}/all-nodes-deployment-hieradata.j2.yaml: {get_param: {{role.name}}AllNodesDeploymentHieradata} + {{role.name}}/deployment-hieradata.j2.yaml: {get_param: {{role.name}}DeploymentHieradata} + {{role.name}}/per-host-hieradata.j2.yaml: {get_param: {{role.name}}PerHostHieradata} {%- endfor %} update_steps_tasks: | {%- for role in roles %} diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index 8fd8611edc..61c625446b 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -1025,6 +1025,14 @@ resources: {%- for role in roles %} {{role.name}}Count: {get_param: {{role.name}}Count} {{role.name}}AllNodesDeploymentHieradata: {get_attr: [{{role.name}}allNodesConfig, all_nodes_config_hieradata]} + {{role.name}}DeploymentHieradata: + map_merge: + list_concat: + - {get_attr: [{{role.name}}, config_datafiles]} + {{role.name}}PerHostHieradata: + map_merge: + list_concat: + - {get_attr: [{{role.name}}, per_host_hieradata_map]} {%- endfor %} ServiceNetMapLower: {get_attr: [ServiceNetMap, service_net_map_lower]} PingTestIpsMap: diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml index bd391b64e1..559fb27ecf 100644 --- a/puppet/role.role.j2.yaml +++ b/puppet/role.role.j2.yaml @@ -675,39 +675,47 @@ resources: {{server_resource_name}}Config: type: OS::Heat::StructuredConfig + depends_on: {{server_resource_name}}ConfigDatafiles properties: group: hiera config: - hierarchy: - - '"%{::uuid}"' - - docker_puppet # Optionally provided by container-puppet.py - - heat_config_%{::deploy_config_name} - - config_step - - {{role.name.lower()}}_extraconfig - - extraconfig - - service_names - - service_configs - - {{role.name.lower()}} - - bootstrap_node # provided by allNodesConfig - - all_nodes # provided by allNodesConfig - - vip_data # provided by allNodesConfig - - net_ip_map - - '"%{::osfamily}"' - # The following are required for compatibility with the Controller role - # where some vendor integrations added hieradata via ExtraConfigPre - - neutron_bigswitch_data # Optionally provided by Controller/ComputeExtraConfigPre - - neutron_cisco_data # Optionally provided by Controller/ComputeExtraConfigPre - - cisco_n1kv_data # Optionally provided by Controller/ComputeExtraConfigPre - - midonet_data #Optionally provided by AllNodesExtraConfig - - cisco_aci_data # Optionally provided by Controller/ComputeExtraConfigPre - # Special variable for upgrade - - upgrade - merge_behavior: deeper + map_merge: + - hierarchy: + - '"%{::uuid}"' + - host_extraconfig + - docker_puppet # Optionally provided by container-puppet.py + - heat_config_%{::deploy_config_name} + - config_step + - {{role.name.lower()}}_extraconfig + - extraconfig + - service_names + - service_configs + - {{role.name.lower()}} + - bootstrap_node # provided by allNodesConfig + - all_nodes # provided by allNodesConfig + - vip_data # provided by allNodesConfig + - net_ip_map + - '"%{::osfamily}"' + # The following are required for compatibility with the Controller role + # where some vendor integrations added hieradata via ExtraConfigPre + - neutron_bigswitch_data # Optionally provided by Controller/ComputeExtraConfigPre + - neutron_cisco_data # Optionally provided by Controller/ComputeExtraConfigPre + - cisco_n1kv_data # Optionally provided by Controller/ComputeExtraConfigPre + - midonet_data #Optionally provided by AllNodesExtraConfig + - cisco_aci_data # Optionally provided by Controller/ComputeExtraConfigPre + # Special variable for upgrade + - upgrade + - merge_behavior: deeper + + {{server_resource_name}}ConfigDatafiles: + type: OS::Heat::Value + properties: + value: + type: json datafiles: service_names: service_names: {get_param: ServiceNames} sensu::subscriptions: {get_param: MonitoringSubscriptions} - net_ip_map: {get_attr: [NetIpMap, net_ip_map]} service_configs: {get_param: ServiceConfigSettings} {{role.name.lower()}}_extraconfig: map_merge: @@ -718,13 +726,6 @@ resources: extraconfig: {get_param: ExtraConfig} {{role.name.lower()}}: tripleo::clouddomain: {get_param: CloudDomain} - {%- 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]} # Resource for site-specific injection of root certificate NodeTLSCAData: @@ -735,7 +736,6 @@ resources: # Hook for site-specific additional pre-deployment config, e.g extra hieradata {{role.name}}ExtraConfigPre: - depends_on: {{server_resource_name}}Deployment type: OS::TripleO::{{role.name}}ExtraConfigPre # We have to use conditions here so that we don't break backwards # compatibility with templates everywhere @@ -767,7 +767,6 @@ resources: SshHostPubKey: type: OS::TripleO::Ssh::HostPubKey - depends_on: {{server_resource_name}}Deployment properties: server: {get_resource: {{server_resource_name}}} deployment_actions: {get_attr: [DeploymentActions, value]} @@ -803,8 +802,6 @@ resources: 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]} @@ -813,6 +810,15 @@ resources: fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]} fqdn_canonical: {get_attr: [NetHostMap, value, canonical, fqdn]} + {{server_resource_name}}PerHostHieradata: + type: OS::Heat::Value + properties: + type: json + value: + datafiles: + host_extraconfig: {get_attr: [{{server_resource_name}}AnsibleHostVars, value]} + net_ip_map: {get_attr: [NetIpMap, net_ip_map]} + outputs: ansible_host_vars_map: @@ -825,6 +831,17 @@ outputs: - host: {get_attr: [{{server_resource_name}}AnsibleHostVars, value]} - keys: host: {get_attr: [{{server_resource_name}}, name]} + per_host_hieradata_map: + description: | + Map of Hieradata specific per host. + value: + map_replace: + - host: {get_attr: [{{server_resource_name}}PerHostHieradata, value]} + - keys: + host: {get_attr: [{{server_resource_name}}, name]} + config_datafiles: + description: The config in the full format with datafiles section. + value: {get_attr: [{{server_resource_name}}ConfigDatafiles, value]} ip_address: description: IP address of the server in the ctlplane network value: {get_attr: [{{server_resource_name}}, networks, ctlplane, 0]}