From 76421eb249051c749c920e600d9caa508d9e7729 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Thu, 20 Jul 2017 15:04:10 +0100 Subject: Move deploy-steps-playbook to deploy-steps-tasks So that we can more easily iterate over an include in an output Change-Id: Idd5bb47589e5c37123caafcded1afbff8881aa33 --- common/deploy-steps-playbook.yaml | 86 --------------------------------------- common/deploy-steps-tasks.yaml | 86 +++++++++++++++++++++++++++++++++++++++ common/deploy-steps.j2 | 10 ++++- 3 files changed, 95 insertions(+), 87 deletions(-) delete mode 100644 common/deploy-steps-playbook.yaml create mode 100644 common/deploy-steps-tasks.yaml (limited to 'common') diff --git a/common/deploy-steps-playbook.yaml b/common/deploy-steps-playbook.yaml deleted file mode 100644 index b884e0e7..00000000 --- a/common/deploy-steps-playbook.yaml +++ /dev/null @@ -1,86 +0,0 @@ -- hosts: localhost - connection: local - tasks: - ##################################################### - # Per step puppet configuration of the baremetal host - ##################################################### - - name: Write the config_step hieradata - copy: content="{{dict(step=step|int)|to_json}}" dest=/etc/puppet/hieradata/config_step.json force=true - - name: Run puppet host configuration for step {{step}} - command: >- - puppet apply - --modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules - --logdest syslog --logdest console --color=false - /var/lib/tripleo-config/puppet_step_config.pp - changed_when: false - check_mode: no - register: outputs - failed_when: false - no_log: true - - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) - when: outputs is defined - failed_when: outputs|failed - ###################################### - # Generate config via docker-puppet.py - ###################################### - - name: Run docker-puppet tasks (generate config) - shell: python /var/lib/docker-puppet/docker-puppet.py - environment: - NET_HOST: 'true' - DEBUG: '{{docker_puppet_debug}}' - when: step == "1" - changed_when: false - check_mode: no - register: outputs - failed_when: false - no_log: true - - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) - when: outputs is defined - failed_when: outputs|failed - ################################################## - # Per step starting of the containers using paunch - ################################################## - - name: Check if /var/lib/hashed-tripleo-config/docker-container-startup-config-step_{{step}}.json exists - stat: - path: /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{step}}.json - register: docker_config_json - # Note docker-puppet.py generates the hashed-*.json file, which is a copy of - # the *step_n.json with a hash of the generated external config added - # This acts as a salt to enable restarting the container if config changes - - name: Start containers for step {{step}} - command: >- - paunch --debug apply - --file /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{step}}.json - --config-id tripleo_step{{step}} --managed-by tripleo-{{role_name}} - when: docker_config_json.stat.exists - changed_when: false - check_mode: no - register: outputs - failed_when: false - no_log: true - - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) - when: outputs is defined - failed_when: outputs|failed - ######################################################## - # Bootstrap tasks, only performed on bootstrap_server_id - ######################################################## - - name: Check if /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json exists - stat: - path: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json - register: docker_puppet_tasks_json - - name: Run docker-puppet tasks (bootstrap tasks) - shell: python /var/lib/docker-puppet/docker-puppet.py - environment: - CONFIG: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json - NET_HOST: "true" - NO_ARCHIVE: "true" - STEP: "{{step}}" - when: deploy_server_id == bootstrap_server_id and docker_puppet_tasks_json.stat.exists - changed_when: false - check_mode: no - register: outputs - failed_when: false - no_log: true - - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) - when: outputs is defined - failed_when: outputs|failed diff --git a/common/deploy-steps-tasks.yaml b/common/deploy-steps-tasks.yaml new file mode 100644 index 00000000..c6935e75 --- /dev/null +++ b/common/deploy-steps-tasks.yaml @@ -0,0 +1,86 @@ + # Note the indentation here is required as it's joined + # to create a playbook in deploy-steps.j2 + + ##################################################### + # Per step puppet configuration of the baremetal host + ##################################################### + - name: Write the config_step hieradata + copy: content="{{dict(step=step|int)|to_json}}" dest=/etc/puppet/hieradata/config_step.json force=true + - name: Run puppet host configuration for step {{step}} + command: >- + puppet apply + --modulepath=/etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules + --logdest syslog --logdest console --color=false + /var/lib/tripleo-config/puppet_step_config.pp + changed_when: false + check_mode: no + register: outputs + failed_when: false + no_log: true + - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) + when: outputs is defined + failed_when: outputs|failed + ###################################### + # Generate config via docker-puppet.py + ###################################### + - name: Run docker-puppet tasks (generate config) + shell: python /var/lib/docker-puppet/docker-puppet.py + environment: + NET_HOST: 'true' + DEBUG: '{{docker_puppet_debug}}' + when: step == "1" + changed_when: false + check_mode: no + register: outputs + failed_when: false + no_log: true + - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) + when: outputs is defined + failed_when: outputs|failed + ################################################## + # Per step starting of the containers using paunch + ################################################## + - name: Check if /var/lib/hashed-tripleo-config/docker-container-startup-config-step_{{step}}.json exists + stat: + path: /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{step}}.json + register: docker_config_json + # Note docker-puppet.py generates the hashed-*.json file, which is a copy of + # the *step_n.json with a hash of the generated external config added + # This acts as a salt to enable restarting the container if config changes + - name: Start containers for step {{step}} + command: >- + paunch --debug apply + --file /var/lib/tripleo-config/hashed-docker-container-startup-config-step_{{step}}.json + --config-id tripleo_step{{step}} --managed-by tripleo-{{role_name}} + when: docker_config_json.stat.exists + changed_when: false + check_mode: no + register: outputs + failed_when: false + no_log: true + - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) + when: outputs is defined + failed_when: outputs|failed + ######################################################## + # Bootstrap tasks, only performed on bootstrap_server_id + ######################################################## + - name: Check if /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json exists + stat: + path: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json + register: docker_puppet_tasks_json + - name: Run docker-puppet tasks (bootstrap tasks) + shell: python /var/lib/docker-puppet/docker-puppet.py + environment: + CONFIG: /var/lib/docker-puppet/docker-puppet-tasks{{step}}.json + NET_HOST: "true" + NO_ARCHIVE: "true" + STEP: "{{step}}" + when: deploy_server_id == bootstrap_server_id and docker_puppet_tasks_json.stat.exists + changed_when: false + check_mode: no + register: outputs + failed_when: false + no_log: true + - debug: var=(outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([])) + when: outputs is defined + failed_when: outputs|failed diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index e5d7e98c..bd8d9bc0 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -72,7 +72,15 @@ resources: - name: update_identifier - name: bootstrap_server_id - name: docker_puppet_debug - config: {get_file: deploy-steps-playbook.yaml} + config: + str_replace: + template: | + - hosts: localhost + connection: local + tasks: + _TASKS + params: + _TASKS: {get_file: deploy-steps-tasks.yaml} {%- for step in range(1, deploy_steps_max) %} # BEGIN service_workflow_tasks handling -- cgit 1.2.3-korg