From a0e6d30ca22da1edc330177fa5939bd25efe05c8 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Wed, 20 Sep 2017 12:48:19 -0400 Subject: [PATCH] Config download support for standalone deployments Presently, "openstack overcloud config download" does not support all Deployment resources, only those included in the RoleData and are natively of type group:ansible. This patch adds support for also pulling all the deployment data for OS::Heat::SoftwareDeployment (singular) resources applied to individual servers of any group type. Those resources are mapped to a new nested stack via the config-download-environment.yaml environment. The nested stack has the same interface as a SoftwareDeployment but only creates a OS::Heat::Value resource. The "config download" code will be updated in a separate patch to read the deployment data from these Value resources and apply them via ansible. The related tripleo-common patch (which depends on this patch) is: I7d7f6b831b8566390d8f747fb6f45e879b0392ba implements: blueprint ansible-config-download Change-Id: Ic2af634403b1ab2924c383035f770453f39a2cd5 --- common/deploy-steps.j2 | 71 ++++++++++----- config-download-software.yaml | 87 +++++++++++++++++++ config-download-structured.yaml | 87 +++++++++++++++++++ deployed-server/deployed-server.yaml | 13 ++- environments/config-download-environment.yaml | 8 ++ extraconfig/tasks/pre_puppet_pacemaker.yaml | 1 + tools/yaml-validate.py | 3 +- 7 files changed, 245 insertions(+), 25 deletions(-) create mode 100644 config-download-software.yaml create mode 100644 config-download-structured.yaml create mode 100644 environments/config-download-environment.yaml diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 9daf93e76d..e509e80267 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -165,6 +165,7 @@ resources: {{role.name}}ArtifactsDeploy: type: OS::Heat::StructuredDeploymentGroup properties: + name: {{role.name}}ArtifactsDeploy servers: {get_param: [servers, {{role.name}}]} config: {get_resource: {{role.name}}ArtifactsConfig} @@ -198,54 +199,53 @@ resources: - {get_param: [role_data, {{role.name}}, host_prep_tasks]} {%- endif %} - -{%- raw %} # Write the manifest for baremetal puppet configuration - name: Create /var/lib/tripleo-config directory file: path=/var/lib/tripleo-config state=directory - name: Write the puppet step_config manifest - copy: content="{{puppet_step_config}}" dest=/var/lib/tripleo-config/puppet_step_config.pp force=yes mode=0600 + copy: content="{{ '{{' }}puppet_step_config{{ '}}' }}" dest=/var/lib/tripleo-config/puppet_step_config.pp force=yes mode=0600 # this creates a JSON config file for our docker-puppet.py script - name: Create /var/lib/docker-puppet file: path=/var/lib/docker-puppet state=directory - name: Write docker-puppet-tasks json files - copy: content="{{puppet_config | to_json}}" dest=/var/lib/docker-puppet/docker-puppet.json force=yes mode=0600 + copy: content="{{ '{{' }}puppet_config | to_json{{ '}}' }}" dest=/var/lib/docker-puppet/docker-puppet.json force=yes mode=0600 # FIXME: can we move docker-puppet somewhere so it's installed via a package? - name: Write docker-puppet.py - copy: content="{{docker_puppet_script}}" dest=/var/lib/docker-puppet/docker-puppet.py force=yes mode=0600 + copy: content="{{ '{{' }}docker_puppet_script{{ '}}' }}" dest=/var/lib/docker-puppet/docker-puppet.py force=yes mode=0600 # Here we are dumping all the docker container startup configuration data # so that we can have access to how they are started outside of heat # and docker-cmd. This lets us create command line tools to test containers. # FIXME do we need the docker-container-startup-configs.json or is the new per-step # data consumed by paunch enough? - name: Write docker-container-startup-configs - copy: content="{{docker_startup_configs | to_json}}" dest=/var/lib/docker-container-startup-configs.json force=yes mode=0600 + copy: content="{{ '{{' }}docker_startup_configs | to_json{{ '}}' }}" dest=/var/lib/docker-container-startup-configs.json force=yes mode=0600 - name: Write per-step docker-container-startup-configs - copy: content="{{item.value|to_json}}" dest="/var/lib/tripleo-config/docker-container-startup-config-{{item.key}}.json" force=yes mode=0600 - with_dict: "{{docker_startup_configs}}" + copy: content="{{ '{{' }}item.value|to_json{{ '}}' }}" dest="/var/lib/tripleo-config/docker-container-startup-config-{{ '{{' }}item.key{{ '}}' }}.json" force=yes mode=0600 + with_dict: "{{ '{{' }}docker_startup_configs{{ '}}' }}" - name: Create /var/lib/kolla/config_files directory file: path=/var/lib/kolla/config_files state=directory - name: Write kolla config json files - copy: content="{{item.value|to_json}}" dest="{{item.key}}" force=yes mode=0600 - with_dict: "{{kolla_config}}" + copy: content="{{ '{{' }}item.value|to_json{{ '}}' }}" dest="{{ '{{' }}item.key{{ '}}' }}" force=yes mode=0600 + with_dict: "{{ '{{' }}kolla_config{{ '}}' }}" ######################################################## # Bootstrap tasks, only performed on bootstrap_server_id ######################################################## - name: Clean /var/lib/docker-puppet/docker-puppet-tasks*.json files file: - path: "{{item}}" + path: "{{ '{{' }}item{{ '}}' }}" state: absent with_fileglob: - /var/lib/docker-puppet/docker-puppet-tasks*.json when: deploy_server_id == bootstrap_server_id - name: Write docker-puppet-tasks json files - copy: content="{{item.value|to_json}}" dest=/var/lib/docker-puppet/docker-puppet-tasks{{item.key.replace("step_", "")}}.json force=yes mode=0600 - with_dict: "{{docker_puppet_tasks}}" + copy: content="{{ '{{' }}item.value|to_json{{ '}}' }}" dest=/var/lib/docker-puppet/docker-puppet-tasks{{ '{{' }}item.key.replace("step_", ""){{ '}}' }}.json force=yes mode=0600 + with_dict: "{{ '{{' }}docker_puppet_tasks{{ '}}' }}" when: deploy_server_id == bootstrap_server_id -{%- endraw %} {{role.name}}HostPrepDeployment: type: OS::Heat::SoftwareDeploymentGroup properties: + name: {{role.name}}HostPrepDeployment servers: {get_param: [servers, {{role.name}}]} config: {get_resource: {{role.name}}HostPrepConfig} {% endfor %} @@ -330,17 +330,44 @@ outputs: description: Mapping of config data for all roles value: deploy_steps_tasks: {get_file: deploy-steps-tasks.yaml} - deploy_steps_playbook: | - - hosts: overcloud - tasks: + deploy_steps_playbook: + str_replace: + params: + BOOTSTRAP_SERVER_ID: {get_param: [servers, {{primary_role_name}}, '0']} + template: | + - hosts: overcloud + name: Server deployments + tasks: {%- for role in roles %} - - include: {{role.name}}/host_prep_tasks.yaml - when: role_name == '{{role.name}}' + - include: {{role.name}}/deployments.yaml + vars: + force: false + when: role_name == '{{role.name}}' + with_items: "{{ '{{' }} {{role.name}}_pre_deployments {{ '}}' }}" +{%- endfor %} + - hosts: overcloud + name: Deployment steps + vars: + bootstrap_server_id: BOOTSTRAP_SERVER_ID + tasks: +{%- for role in roles %} + - include: {{role.name}}/host_prep_tasks.yaml + when: role_name == '{{role.name}}' +{%- endfor %} + - include: deploy_steps_tasks.yaml + with_sequence: count={{deploy_steps_max-1}} + loop_control: + loop_var: step + - hosts: overcloud + name: Server Post Deployments + tasks: +{%- for role in roles %} + - include: {{role.name}}/deployments.yaml + vars: + force: false + when: role_name == '{{role.name}}' + with_items: "{{ '{{' }} {{role.name}}_post_deployments {{ '}}' }}" {%- endfor %} - - include: deploy_steps_tasks.yaml - with_sequence: count={{deploy_steps_max-1}} - loop_control: - loop_var: step update_steps_tasks: | {%- for role in roles %} - include: {{role.name}}/update_tasks.yaml diff --git a/config-download-software.yaml b/config-download-software.yaml new file mode 100644 index 0000000000..4422088a06 --- /dev/null +++ b/config-download-software.yaml @@ -0,0 +1,87 @@ +heat_template_version: pike + +parameters: + + name: + type: string + + actions: + type: comma_delimited_list + default: ['CREATE', 'UPDATE'] + + server: + type: string + + config: + type: string + + input_values: + type: json + description: input values for the software deployments + default: {} + + input_key: + type: string + default: 'get_input' + + signal_transport: + type: string + default: 'CFN_SIGNAL' + + input_values_validate: + type: string + default: 'LAX' + +resources: + + TripleODeployment: + type: OS::Heat::Value + properties: + value: + name: {get_param: name} + server: {get_param: server} + config: {get_param: config} + input_values: {get_param: input_values} + deployment: {get_resource: TripleOSoftwareDeployment} + + TripleOSoftwareDeployment: + type: OS::Heat::SoftwareDeployment + properties: + name: deployment_resource + config: {get_param: config} + server: {get_resource: TripleOServer} + input_values: {get_param: input_values} + signal_transport: NO_SIGNAL + actions: {get_param: actions} + + TripleOServer: + type: OS::Heat::DeployedServer + properties: + name: server_resource + +outputs: + + deploy_status_code: + value: 0 + deploy_stderr: + value: '' + deploy_stdout: + value: '' + show: + value: '' + + ecdsa: + description: Host ssh public key (ecdsa) + value: 'ecdsa' + rsa: + description: Host ssh public key (rsa) + value: 'rsa' + ed25519: + description: Host ssh public key (ed25519) + value: 'ed25519' + update_managed_packages: + description: boolean value indicating whether to upgrade managed packages + value: false + hostname: + description: hostname + value: '' diff --git a/config-download-structured.yaml b/config-download-structured.yaml new file mode 100644 index 0000000000..b699c18a47 --- /dev/null +++ b/config-download-structured.yaml @@ -0,0 +1,87 @@ +heat_template_version: pike + +parameters: + + name: + type: string + + actions: + type: comma_delimited_list + default: ['CREATE', 'UPDATE'] + + server: + type: string + + config: + type: string + + input_values: + type: json + description: input values for the software deployments + default: {} + + input_key: + type: string + default: 'get_input' + + signal_transport: + type: string + default: 'CFN_SIGNAL' + + input_values_validate: + type: string + default: 'LAX' + +resources: + + TripleODeployment: + type: OS::Heat::Value + properties: + value: + name: {get_param: name} + server: {get_param: server} + config: {get_param: config} + input_values: {get_param: input_values} + deployment: {get_resource: TripleOSoftwareDeployment} + + TripleOSoftwareDeployment: + type: OS::Heat::StructuredDeployment + properties: + name: deployment_resource + config: {get_param: config} + server: {get_resource: TripleOServer} + input_values: {get_param: input_values} + signal_transport: NO_SIGNAL + actions: {get_param: actions} + + TripleOServer: + type: OS::Heat::DeployedServer + properties: + name: server_resource + +outputs: + + deploy_status_code: + value: 0 + deploy_stderr: + value: '' + deploy_stdout: + value: '' + show: + value: '' + + ecdsa: + description: Host ssh public key (ecdsa) + value: 'ecdsa' + rsa: + description: Host ssh public key (rsa) + value: 'rsa' + ed25519: + description: Host ssh public key (ed25519) + value: 'ed25519' + update_managed_packages: + description: boolean value indicating whether to upgrade managed packages + value: false + hostname: + description: hostname + value: '' diff --git a/deployed-server/deployed-server.yaml b/deployed-server/deployed-server.yaml index d116e7c678..29216ac849 100644 --- a/deployed-server/deployed-server.yaml +++ b/deployed-server/deployed-server.yaml @@ -125,7 +125,11 @@ resources: name: list_join: - '-' - - - {get_attr: [HostsEntryDeployment, hostname]} + - - yaql: + expression: switch(not $.data.hostname.isEmpty() => $.data.hostname, $.data.name=>$.data.name) + data: + hostname: {get_attr: [HostsEntryDeployment, hostname]} + name: {get_param: name} - ctlplane replacement_policy: AUTO @@ -137,6 +141,11 @@ outputs: ctlplane: - {get_attr: [ControlPlanePort, fixed_ips, 0, ip_address]} name: - value: {get_attr: [HostsEntryDeployment, hostname]} + value: + yaql: + expression: switch(not $.data.hostname.isEmpty() => $.data.hostname, $.data.name=>$.data.name) + data: + hostname: {get_attr: [HostsEntryDeployment, hostname]} + name: {get_param: name} os_collect_config: value: {get_attr: [deployed-server, os_collect_config]} diff --git a/environments/config-download-environment.yaml b/environments/config-download-environment.yaml new file mode 100644 index 0000000000..da97c929ef --- /dev/null +++ b/environments/config-download-environment.yaml @@ -0,0 +1,8 @@ +resource_registry: + OS::TripleO::SoftwareDeployment: ../config-download-structured.yaml + OS::TripleO::StructuredDeployment: ../config-download-structured.yaml + + OS::Heat::SoftwareDeployment: ../config-download-software.yaml + OS::Heat::StructuredDeployment: ../config-download-structured.yaml + + OS::TripleO::DeploymentSteps: OS::Heat::None diff --git a/extraconfig/tasks/pre_puppet_pacemaker.yaml b/extraconfig/tasks/pre_puppet_pacemaker.yaml index 98b37be797..90f2630b0e 100644 --- a/extraconfig/tasks/pre_puppet_pacemaker.yaml +++ b/extraconfig/tasks/pre_puppet_pacemaker.yaml @@ -20,6 +20,7 @@ resources: ControllerPrePuppetMaintenanceModeDeployment: type: OS::Heat::SoftwareDeployments properties: + name: ControllerPrePuppetMaintenanceModeDeployment servers: {get_param: servers} config: {get_resource: ControllerPrePuppetMaintenanceModeConfig} input_values: {get_param: input_values} diff --git a/tools/yaml-validate.py b/tools/yaml-validate.py index 617b390d6b..a69a614784 100755 --- a/tools/yaml-validate.py +++ b/tools/yaml-validate.py @@ -119,7 +119,8 @@ PARAMETER_DEFINITION_EXCLUSIONS = {'ManagementNetCidr': ['default'], 'ControllerExtraConfig': ['description'], 'NovaComputeExtraConfig': ['description'], 'controllerExtraConfig': ['description'], - 'DockerSwiftConfigImage': ['default'] + 'DockerSwiftConfigImage': ['default'], + 'input_values': ['default'] } PREFERRED_CAMEL_CASE = {