tripleo-common/workbooks/deployment.yaml

982 lines
30 KiB
YAML

---
version: '2.0'
name: tripleo.deployment.v1
description: TripleO deployment workflows
workflows:
deploy_on_server:
input:
- server_uuid
- server_name
- config
- config_name
- group
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
deploy_config:
action: tripleo.deployment.config
on-complete: send_message
input:
server_id: <% $.server_uuid %>
name: <% $.config_name %>
config: <% $.config %>
group: <% $.group %>
publish:
stdout: <% task().result.deploy_stdout %>
stderr: <% task().result.deploy_stderr %>
status_code: <% task().result.deploy_status_code %>
publish-on-error:
status: FAILED
message: <% task().result %>
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
execution: <% execution() %>
status: <% $.get("status", "SUCCESS") %>
message: <% $.get("message", "") %>
payload:
server_uuid: <% $.server_uuid %>
server_name: <% $.server_name %>
config_name: <% $.config_name %>
status_code: <% $.get("status_code", "") %>
stdout: <% $.get("stdout", "") %>
stderr: <% $.get("stderr", "") %>
deploy_on_servers:
input:
- server_name
- config_name
- config
- group: script
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
check_if_all_servers:
on-success:
- get_servers_matching: <% $.server_name != "all" %>
- get_all_servers: <% $.server_name = "all" %>
get_servers_matching:
action: nova.servers_list
on-success: deploy_on_servers
publish:
servers_with_name: <% task().result._info.where($.name.indexOf(execution().input.server_name) > -1) %>
get_all_servers:
action: nova.servers_list
on-success: deploy_on_servers
publish:
servers_with_name: <% task().result._info %>
deploy_on_servers:
on-success: send_success_message
on-error: send_failed_message
with-items: server in <% $.servers_with_name %>
workflow: tripleo.deployment.v1.deploy_on_server
input:
server_name: <% $.server.name %>
server_uuid: <% $.server.id %>
config: <% $.config %>
config_name: <% $.config_name %>
group: <% $.group %>
queue_name: <% $.queue_name %>
send_success_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: SUCCESS
execution: <% execution() %>
send_failed_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: FAILED
execution: <% execution() %>
message: <% task(deploy_on_servers).result %>
deploy_plan:
description: >
Deploy the overcloud for a plan.
input:
- container
- run_validations: False
- timeout: 240
- skip_deploy_identifier: False
- queue_name: tripleo
- config_download: False
- ssh_network: ctlplane
- deployment_options: {}
tags:
- tripleo-common-managed
tasks:
send_start_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: RUNNING
deployment_status: DEPLOYING
message: "Initializing <% $.container %> plan deployment"
execution: <% execution() %>
plan_name: <% $.container %>
on-complete: add_validation_ssh_key
add_validation_ssh_key:
workflow: tripleo.validations.v1.add_validation_ssh_key_parameter
input:
container: <% $.container %>
queue_name: <% $.queue_name %>
on-complete:
- run_validations: <% $.run_validations %>
- container_image_prepare_params: <% not $.run_validations %>
run_validations:
workflow: tripleo.validations.v1.run_groups
input:
group_names:
- 'pre-deployment'
plan: <% $.container %>
queue_name: <% $.queue_name %>
publish-on-error:
message: <% task().result %>
on-success: container_image_prepare_params
on-error: set_deployment_failed
container_image_prepare_params:
action: tripleo.container_images.prepare_params
input:
container: <% $.container %>
publish-on-error:
message: <% task().result %>
on-success: create_swift_rings_backup_plan
on-error: set_deployment_failed
create_swift_rings_backup_plan:
workflow: tripleo.swift_backup.v1.create_swift_backup_container_plan
input:
container: <% $.container %>
queue_name: <% $.queue_name %>
container_suffix: "-swift-rings"
swift_tar: "swift-rings.tar.gz"
get_url_parm: SwiftRingGetTempurl
put_url_parm: SwiftRingPutTempurl
use_default_templates: true
publish-on-error:
message: <% task().result %>
on-success: create_ceph_ansible_fetch_directory_backup_plan
on-error: set_deployment_failed
create_ceph_ansible_fetch_directory_backup_plan:
workflow: tripleo.swift_backup.v1.create_swift_backup_container_plan
input:
container: <% $.container %>
queue_name: <% $.queue_name %>
container_suffix: "_ceph_ansible_fetch_dir"
swift_tar: "temporary_dir.tar.gz"
get_url_parm: SwiftFetchDirGetTempurl
put_url_parm: SwiftFetchDirPutTempurl
use_default_templates: true
publish-on-error:
message: <% task().result %>
on-success: cell_v2_discover_hosts
on-error: set_deployment_failed
cell_v2_discover_hosts:
action: tripleo.baremetal.cell_v2_discover_hosts
publish-on-error:
message: <% task().result %>
on-success: send_stack_deployment_message
on-error: set_deployment_failed
send_stack_deployment_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: RUNNING
deployment_status: DEPLOYING
message: "Creating <% $.container %> Heat stack"
execution: <% execution() %>
plan_name: <% $.container %>
on-complete: deploy
deploy:
action: tripleo.deployment.deploy
input:
timeout: <% $.timeout %>
container: <% $.container %>
skip_deploy_identifier: <% $.skip_deploy_identifier %>
publish-on-error:
message: <% task().result %>
on-success:
- wait_for_stack_complete: <% $.config_download %>
- set_deployment_deploying: <% not $.config_download %>
on-error: set_deployment_failed
wait_for_stack_complete:
workflow: tripleo.stack.v1.wait_for_stack_complete_or_failed
input:
stack: <% $.container %>
queue_name: <% $.queue_name %>
publish-on-error:
message: <% task().result %>
publish:
message: Stack status <% task().result.stack_status %>
on-error: set_deployment_failed
on-success:
- message_stack_complete: <% task().result.stack_status = "CREATE_COMPLETE" %>
- get_servers: <% task().result.stack_status = "CREATE_COMPLETE" %>
- set_deployment_failed: <% task().result.stack_status != "CREATE_COMPLETE" %>
message_stack_complete:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.get('status', 'RUNNING') %>
deployment_status: DEPLOYING
execution: <% execution() %>
plan_name: <% $.container %>
message: <% $.get("message", "") %>
get_servers:
action: nova.servers_list
publish:
# FIXME(mandre) we want only the servers part of the plan
servers: <% task().result._info.select($.addresses.ctlplane.addr).flatten() %>
publish-on-error:
message: <% task().result %>
on-success: get_private_key
on-error: set_deployment_failed
get_private_key:
action: tripleo.validations.get_privkey
publish:
private_key: <% task().result %>
publish-on-error:
message: <% task().result %>
on-success: enable_ssh_admin
on-error: set_deployment_failed
enable_ssh_admin:
workflow: tripleo.access.v1.enable_ssh_admin
input:
ssh_servers: <% $.servers %>
ssh_private_key: <% $.private_key %>
# FIXME(mandre) this shouldn't be hardcoded
ssh_user: heat-admin
plan_name: <% $.container %>
publish-on-error:
message: <% task().result %>
on-success: config_download_deploy
on-error: set_deployment_failed
config_download_deploy:
workflow: config_download_deploy
input:
plan_name: <% $.container %>
queue_name: <% $.queue_name %>
ssh_network: <% $.get('ssh_network') %>
publish-on-error:
message: <% task().result %>
on-success: set_deployment_success
on-error: set_deployment_failed
set_deployment_failed:
on-success: send_message
publish:
status: FAILED
deployment_status: DEPLOY_FAILED
set_deployment_success:
on-success: send_message
publish:
status: SUCCESS
deployment_status: DEPLOY_SUCCESS
set_deployment_deploying:
on-success: send_message
publish:
status: SUCCESS
deployment_status: DEPLOYING
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
plan_name: <% $.container %>
deployment_status: <% $.deployment_status %>
get_horizon_url:
description: >
Retrieve the Horizon URL from the Overcloud stack.
input:
- stack: overcloud
- queue_name: tripleo
tags:
- tripleo-common-managed
output:
horizon_url: <% $.horizon_url %>
tasks:
get_horizon_url:
action: heat.stacks_output_show
input:
stack_id: <% $.stack %>
output_key: EndpointMap
publish:
horizon_url: <% task().result.output.output_value.HorizonPublic.uri %>
on-success: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.get('status', 'SUCCESS') %>
execution: <% execution() %>
message: <% $.get('message', '') %>
payload:
horizon_url: <% $.get('horizon_url', '') %>
config_download_deploy:
description: >
Configure the overcloud with config-download.
input:
- queue_name: tripleo
- plan_name: overcloud
- ssh_network: ctlplane
- work_dir: /var/lib/mistral
- verbosity: 1
- blacklist: []
- override_ansible_cfg: ""
- config_download_timeout: 14400
tags:
- tripleo-common-managed
tasks:
check_for_deploy_in_progress:
action: mistral.executions_find
input:
workflow_name: tripleo.deployment.v1.config_download_deploy
state: RUNNING
publish:
running_config_download_workflows: <% task().result.where($.id != execution().id) %>
on-success:
- fail_deploy_in_progress: <% $.running_config_download_workflows != [] %>
- get_blacklisted_hostnames: <% $.running_config_download_workflows = [] %>
fail_deploy_in_progress:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.get('status', 'FAILED') %>
execution: <% execution() %>
message: Deployment already in progress with execution <% $.running_config_download_workflows[0].id %>
plan_name: <% $.plan_name %>
on-complete: fail
get_blacklisted_hostnames:
action: heat.stacks_output_show
input:
stack_id: <% $.plan_name %>
output_key: BlacklistedHostnames
publish:
blacklisted_hostnames: <% task().result.output.output_value.where($ != "") %>
on-success: get_config
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
deployment_status: DEPLOY_FAILED
get_config:
action: tripleo.config.get_overcloud_config
input:
container: <% $.get('plan_name') %>
container_config: <% $.get('plan_name') %>-config
on-success: download_config
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
deployment_status: DEPLOY_FAILED
download_config:
action: tripleo.config.download_config
input:
work_dir: <% $.get('work_dir') %>/<% $.get('plan_name') %>
container_config: <% $.get('plan_name') %>-config
on-success: send_msg_config_download
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
deployment_status: DEPLOY_FAILED
send_msg_config_download:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.get('status', 'RUNNING') %>
deployment_status: DEPLOYING
execution: <% execution() %>
message: Config downloaded at <% $.get('work_dir') %>/<% $.get('plan_name') %>
plan_name: <% $.plan_name %>
on-success: get_private_key
get_private_key:
action: tripleo.validations.get_privkey
publish:
private_key: <% task().result %>
on-success: generate_inventory
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
deployment_status: DEPLOY_FAILED
generate_inventory:
action: tripleo.ansible-generate-inventory
input:
ansible_ssh_user: tripleo-admin
ansible_python_interpreter: <% $.get('deployment_options', {}).get('ansible_python_interpreter', null) %>
work_dir: <% $.get('work_dir') %>/<% $.get('plan_name') %>
plan_name: <% $.get('plan_name') %>
ssh_network: <% $.get('ssh_network') %>
publish:
inventory: <% task().result %>
on-success: send_msg_generate_inventory
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
deployment_status: DEPLOY_FAILED
send_msg_generate_inventory:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.get('status', 'RUNNING') %>
deployment_status: DEPLOYING
execution: <% execution() %>
message: Inventory generated at <% $.get('inventory') %>
plan_name: <% $.plan_name %>
on-success: send_msg_run_ansible
send_msg_run_ansible:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.get('status', 'RUNNING') %>
deployment_status: DEPLOYING
execution: <% execution() %>
plan_name: <% $.plan_name %>
message: >
Running ansible playbook at <% $.get('work_dir') %>/<% $.get('plan_name') %>/deploy_steps_playbook.yaml.
See log file at <% $.get('work_dir') %>/<% $.get('plan_name') %>/ansible.log for progress.
...
on-success: run_ansible
run_ansible:
action: tripleo.ansible-playbook
input:
inventory: <% $.inventory %>
playbook: <% $.get('work_dir') %>/<% $.get('plan_name') %>/deploy_steps_playbook.yaml
playbook_name: deploy_steps_playbook.yaml
plan_name: <% $.plan_name %>
remote_user: tripleo-admin
ssh_private_key: <% $.private_key %>
use_openstack_credentials: true
verbosity: <% $.get('verbosity') %>
become: true
work_dir: <% $.get('work_dir') %>/<% $.get('plan_name') %>
queue_name: <% $.queue_name %>
reproduce_command: true
trash_output: true
blacklisted_hostnames: <% $.blacklisted_hostnames %>
override_ansible_cfg: <% $.override_ansible_cfg %>
command_timeout: <% $.config_download_timeout %>
execution_id: <% execution().id %>
publish:
log_path: <% task().result.get('log_path') %>
deployment_status: DEPLOY_SUCCESS
on-success:
- ansible_passed: <% task().result.returncode = 0 %>
- ansible_timeout: <% task().result.returncode = 124 %>
- ansible_failed: <% not task().result.returncode in [0, 124] %>
on-error: send_message
publish-on-error:
status: FAILED
message: Ansible failed, check log at <% $.get('work_dir') %>/<% $.get('plan_name') %>/ansible.log.
deployment_status: DEPLOY_FAILED
ansible_passed:
on-success: send_message
publish:
status: SUCCESS
message: Ansible passed.
deployment_status: DEPLOY_SUCCESS
ansible_timeout:
on-success: send_message
publish:
status: FAILED
message: Ansible timed out at <% $.config_download_timeout %> seconds.
deployment_status: DEPLOY_FAILED
ansible_failed:
on-success: send_message
publish:
status: FAILED
message: Ansible failed, check log at <% $.get('work_dir') %>/<% $.get('plan_name') %>/ansible.log.
deployment_status: DEPLOY_FAILED
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.get('status', 'SUCCESS') %>
execution: <% execution() %>
message: <% $.get('message', '') %>
plan_name: <% $.plan_name %>
deployment_status: <% $.deployment_status %>
config_download_export:
description: Creates an export tarball and an associated Swift tempurl for config-download for the given plan.
input:
- plan
- queue_name: tripleo
- config_type: ""
tags:
- tripleo-common-managed
tasks:
get_config:
action: tripleo.config.get_overcloud_config
input:
container: <% $.plan %>
container_config: <% $.plan %>-config
config_type: <% $.config_type %>
on-success: create_tempurl
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
create_tempurl:
action: tripleo.swift.tempurl
on-success: set_status_success
on-error: send_message
input:
container: <% $.plan %>-config
obj: "<% $.plan %>-config.tar.gz"
valid: 3600
publish-on-error:
status: FAILED
message: <% task().result %>
set_status_success:
on-success: send_message
publish:
status: SUCCESS
message: "config-download export successful"
tempurl: <% task(create_tempurl).result %>
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
execution: <% execution() %>
plan_name: <% $.plan %>
message: <% $.get('message', '') %>
payload:
tempurl: <% $.get('tempurl', '') %>
undeploy_plan:
description: >
Undeploy a plan.
input:
- container
- timeout: 240
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
send_start_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: RUNNING
deployment_status: UNDEPLOYING
message: "Deleting <% $.container %> deployment"
execution: <% execution() %>
plan_name: <% $.container %>
on-complete: delete_stack
delete_stack:
workflow: tripleo.stack.v1.delete_stack
input:
stack: <% $.container %>
queue_name: <% $.queue_name %>
on-complete: send_undeployed_message
publish-on-error:
status: FAILED
deployment_status: UNDEPLOY_FAILED
message: "Failed to delete <% $.container %> deployment: <% task().result %>"
publish:
status: SUCCESS
deployment_status: UNDEPLOYED
message: "Deleted <% $.container %> deployment"
send_undeployed_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
deployment_status: <% $.deployment_status %>
message: <% $.message %>
execution: <% execution() %>
plan_name: <% $.container %>
create_overcloudrc:
description: >
Given the name of a container and optionally a comma-separated string
of hosts that shouldn't be proxied, generate the overcloudrc files
needed to access the overcloud via the CLI.
tags:
- tripleo-common-managed
input:
- container: overcloud
- no_proxy: ''
- queue_name: tripleo
tasks:
generate_overcloud_rc:
action: tripleo.deployment.overcloudrc
input:
container: <% $.container %>
no_proxy: <% $.no_proxy %>
on-complete: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
publish:
status: SUCCESS
message: <% task().result %>
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
execution: <% execution() %>
message: <% $.get('message', '') %>
get_deployment_status:
description: >
Get deployment status and update it if needed based on stack and
config_downlooad status.
tags:
- tripleo-common-managed
input:
- plan: overcloud
- queue_name: tripleo
output:
deployment_status: <% $.deployment_status %>
tasks:
get_deployment_status:
action: tripleo.deployment.get_deployment_status
input:
plan: <% $.plan %>
publish:
status_update: <% yaml_parse(coalesce(task().result.status_update, '')) %>
deployment_status: <% task().result.deployment_status %>
on-complete:
- reload_deployment_status: <% $.status_update = null and $.deployment_status != null %>
- update_status: <% $.status_update != null and $.deployment_status != null %>
- send_message: <% $.deployment_status = null %>
publish-on-error:
message: No deployment status found for plan <% $.plan %>
deployment_status: ""
update_status:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: RUNNING
execution: <% execution() %>
plan_name: <% $.plan %>
deployment_status: <% $.status_update %>
on-complete: reload_deployment_status
reload_deployment_status:
action: swift.get_object
input:
container: <% $.plan %>-messages
obj: deployment_status.yaml
publish:
deployment_status: <% yaml_parse(task().result.last()) %>
on-complete: send_message
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
execution: <% execution() %>
status: <% $.get("status", "SUCCESS") %>
payload:
deployment_status: <% $.get(deployment_status, "") %>
set_deployment_status_success:
description: >
Set deployment status to success and return the new status
tags:
- tripleo-common-managed
input:
- plan: overcloud
- queue_name: tripleo
output:
deployment_status: <% $.deployment_status %>
tasks:
set_deployment_success:
on-success: send_message
publish:
status: SUCCESS
deployment_status: DEPLOY_SUCCESS
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
plan_name: <% $.plan %>
deployment_status: <% $.deployment_status %>
payload:
deployment_status: <% $.deployment_status %>
set_deployment_status_failed:
description: >
Set deployment status to failed and return the new status
tags:
- tripleo-common-managed
input:
- plan: overcloud
- queue_name: tripleo
output:
deployment_status: <% $.deployment_status %>
tasks:
set_deployment_failed:
on-success: send_message
publish:
status: SUCCESS
deployment_status: DEPLOY_FAILED
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
plan_name: <% $.plan %>
deployment_status: <% $.deployment_status %>
payload:
deployment_status: <% $.deployment_status %>
set_deployment_status_deploying:
description: >
Set deployment status to deploying and return the new status
tags:
- tripleo-common-managed
input:
- plan: overcloud
- queue_name: tripleo
output:
deployment_status: <% $.deployment_status %>
tasks:
set_deployment_failed:
on-success: send_message
publish:
status: SUCCESS
deployment_status: DEPLOYING
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
plan_name: <% $.plan %>
deployment_status: <% $.deployment_status %>
payload:
deployment_status: <% $.deployment_status %>
get_deployment_failures:
description: >
Get deployment failures
tags:
- tripleo-common-managed
input:
- plan: overcloud
- queue_name: tripleo
output:
deployment_failures: <% $.deployment_failures %>
tasks:
get_deployment_failures:
action: tripleo.deployment.get_deployment_failures
input:
plan: <% $.plan %>
publish:
deployment_failures: <% task().result.failures %>
message: <% task().result.message %>
status: <% task().result.message and "FAILED" or "SUCCESS" %>
on-complete: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
execution: <% execution() %>
status: <% $.get("status", "SUCCESS") %>
message: <% $.get("message", "") %>
payload:
deployment_failures: <% $.get(deployment_failures, "") %>
recover_deployment_status:
description: >
Convert an existing deployment into one that supports config-download
tags:
- tripleo-common-managed
input:
- container: overcloud
- queue_name: tripleo
tasks:
query:
action: heat.stacks_get
input:
stack_id: <% $.container %>
publish:
stack_status: <% task().result.stack_status %>
message: <% task().result.stack_status_reason %>
publish-on-error:
stack_status: NO_STACK
on-success: convert_deployment_status
on-error: convert_deployment_status
convert_deployment_status:
action: tripleo.deployment.convert_status
input:
status: <% $.stack_status %>
publish:
deployment_status: <% task().result %>
on-complete: recover
recover:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
type: <% execution().name %>
execution: <% execution() %>
deployment_status: <% $.deployment_status %>
plan_name: <% $.container %>
message: <% $.get('message', '') %>