tripleo-common/workbooks/plan_management.yaml
Ryan Brady f70830b425 Select Roles Workflow
This patch adds a workflow that takes a list of role names as
input and populates roles_data.yaml in container in Swift with
respective roles from 'roles directory'.

Change-Id: I6c2a0d120d3e362df1ce1b701597d062783a48a4
Implements: blueprint tripleo-common-select-roles-workflow
2018-01-26 14:27:53 -05:00

1386 lines
43 KiB
YAML

---
version: '2.0'
name: tripleo.plan_management.v1
description: TripleO Overcloud Deployment Workflows v1
workflows:
create_default_deployment_plan:
description: >
This workflow exists to maintain backwards compatibility in pike. This
workflow will likely be removed in queens in favor of create_deployment_plan.
input:
- container
- queue_name: tripleo
- generate_passwords: true
tags:
- tripleo-common-managed
tasks:
call_create_deployment_plan:
workflow: tripleo.plan_management.v1.create_deployment_plan
on-success: set_status_success
on-error: call_create_deployment_plan_set_status_failed
input:
container: <% $.container %>
queue_name: <% $.queue_name %>
generate_passwords: <% $.generate_passwords %>
use_default_templates: true
set_status_success:
on-success: notify_zaqar
publish:
status: SUCCESS
message: <% task(call_create_deployment_plan).result %>
call_create_deployment_plan_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(call_create_deployment_plan).result %>
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.create_default_deployment_plan
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
create_deployment_plan:
description: >
This workflow provides the capability to create a deployment plan using
the default heat templates provided in a standard TripleO undercloud
deployment, heat templates contained in an external git repository, or a
swift container that already contains templates.
input:
- container
- source_url: null
- queue_name: tripleo
- generate_passwords: true
- use_default_templates: false
tags:
- tripleo-common-managed
tasks:
container_required_check:
description: >
If using the default templates or importing templates from a git
repository, a new container needs to be created. If using an existing
container containing templates, skip straight to create_plan.
on-success:
- verify_container_doesnt_exist: <% $.use_default_templates or $.source_url %>
- create_plan: <% $.use_default_templates = false and $.source_url = null %>
verify_container_doesnt_exist:
action: swift.head_container container=<% $.container %>
on-success: notify_zaqar
on-error: create_container
publish:
status: FAILED
message: "Unable to create plan. The Swift container already exists"
create_container:
action: tripleo.plan.create_container container=<% $.container %>
on-success: templates_source_check
on-error: create_container_set_status_failed
cleanup_temporary_files:
action: tripleo.git.clean container=<% $.container %>
templates_source_check:
on-success:
- upload_default_templates: <% $.use_default_templates = true %>
- clone_git_repo: <% $.source_url != null %>
clone_git_repo:
action: tripleo.git.clone container=<% $.container %> url=<% $.source_url %>
on-success: upload_templates_directory
on-error: clone_git_repo_set_status_failed
upload_templates_directory:
action: tripleo.templates.upload container=<% $.container %> templates_path=<% task(clone_git_repo).result %>
on-success: create_plan
on-complete: cleanup_temporary_files
on-error: upload_templates_directory_set_status_failed
upload_default_templates:
action: tripleo.templates.upload container=<% $.container %>
on-success: create_plan
on-error: upload_to_container_set_status_failed
create_plan:
on-success:
- ensure_passwords_exist: <% $.generate_passwords = true %>
- add_root_stack_name: <% $.generate_passwords != true %>
ensure_passwords_exist:
action: tripleo.parameters.generate_passwords container=<% $.container %>
on-success: add_root_stack_name
on-error: ensure_passwords_exist_set_status_failed
add_root_stack_name:
action: tripleo.parameters.update
input:
container: <% $.container %>
parameters:
RootStackName: <% $.container %>
on-success: container_images_prepare
publish-on-error:
status: FAILED
message: <% task().result %>
on-error: notify_zaqar
container_images_prepare:
description: >
Populate all container image parameters with default values.
action: tripleo.container_images.prepare container=<% $.container %>
on-success: process_templates
on-error: container_images_prepare_set_status_failed
process_templates:
action: tripleo.templates.process container=<% $.container %>
on-success: set_status_success
on-error: process_templates_set_status_failed
set_status_success:
on-success: notify_zaqar
publish:
status: SUCCESS
message: 'Plan created.'
create_container_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(create_container).result %>
clone_git_repo_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(clone_git_repo).result %>
upload_templates_directory_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(upload_templates_directory).result %>
upload_to_container_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(upload_default_templates).result %>
ensure_passwords_exist_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(ensure_passwords_exist).result %>
process_templates_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(process_templates).result %>
container_images_prepare_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(container_images_prepare).result %>
notify_zaqar:
action: zaqar.queue_post
retry: count=5 delay=1
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.create_deployment_plan
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
update_deployment_plan:
input:
- container
- source_url: null
- queue_name: tripleo
- generate_passwords: true
tags:
- tripleo-common-managed
tasks:
templates_source_check:
on-success:
- update_plan: <% $.source_url = null %>
- clone_git_repo: <% $.source_url != null %>
clone_git_repo:
action: tripleo.git.clone container=<% $.container %> url=<% $.source_url %>
on-success: upload_templates_directory
on-error: clone_git_repo_set_status_failed
upload_templates_directory:
action: tripleo.templates.upload container=<% $.container %> templates_path=<% task(clone_git_repo).result %>
on-success: create_swift_rings_backup_plan
on-complete: cleanup_temporary_files
on-error: upload_templates_directory_set_status_failed
cleanup_temporary_files:
action: tripleo.git.clean container=<% $.container %>
create_swift_rings_backup_plan:
workflow: tripleo.swift_rings_backup.v1.create_swift_rings_backup_container_plan
on-success: update_plan
on-error: create_swift_rings_backup_plan_set_status_failed
input:
container: <% $.container %>
queue_name: <% $.queue_name %>
use_default_templates: true
update_plan:
on-success:
- ensure_passwords_exist: <% $.generate_passwords = true %>
- container_images_prepare: <% $.generate_passwords != true %>
ensure_passwords_exist:
action: tripleo.parameters.generate_passwords container=<% $.container %>
on-success: container_images_prepare
on-error: ensure_passwords_exist_set_status_failed
container_images_prepare:
description: >
Populate all container image parameters with default values.
action: tripleo.container_images.prepare container=<% $.container %>
on-success: process_templates
on-error: container_images_prepare_set_status_failed
process_templates:
action: tripleo.templates.process container=<% $.container %>
on-success: set_status_success
on-error: process_templates_set_status_failed
set_status_success:
on-success: notify_zaqar
publish:
status: SUCCESS
message: 'Plan updated.'
create_swift_rings_backup_plan_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(create_swift_rings_backup_plan).result %>
clone_git_repo_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(clone_git_repo).result %>
upload_templates_directory_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(upload_templates_directory).result %>
process_templates_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(process_templates).result %>
ensure_passwords_exist_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(ensure_passwords_exist).result %>
container_images_prepare_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(container_images_prepare).result %>
notify_zaqar:
action: zaqar.queue_post
retry: count=5 delay=1
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.update_deployment_plan
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
get_passwords:
description: Retrieves passwords for a given plan
input:
- container
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
verify_container_exists:
action: swift.head_container container=<% $.container %>
on-success: get_environment_passwords
on-error: verify_container_set_status_failed
get_environment_passwords:
action: tripleo.parameters.get_passwords container=<% $.container %>
on-success: get_passwords_set_status_success
on-error: get_passwords_set_status_failed
get_passwords_set_status_success:
on-success: notify_zaqar
publish:
status: SUCCESS
message: <% task(get_environment_passwords).result %>
get_passwords_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(get_environment_passwords).result %>
verify_container_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(verify_container_exists).result %>
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.get_passwords
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
export_deployment_plan:
description: Creates an export tarball for a given plan
input:
- plan
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
export_plan:
action: tripleo.plan.export
input:
plan: <% $.plan %>
delete_after: 3600
exports_container: "plan-exports"
on-success: create_tempurl
on-error: export_plan_set_status_failed
create_tempurl:
action: tripleo.swift.tempurl
on-success: set_status_success
on-error: create_tempurl_set_status_failed
input:
container: "plan-exports"
obj: "<% $.plan %>.tar.gz"
valid: 3600
set_status_success:
on-success: notify_zaqar
publish:
status: SUCCESS
message: <% task(create_tempurl).result %>
tempurl: <% task(create_tempurl).result %>
export_plan_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(export_plan).result %>
create_tempurl_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(create_tempurl).result %>
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.export_deployment_plan
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
tempurl: <% $.get('tempurl', '') %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
get_deprecated_parameters:
description: Gets the list of deprecated parameters in the whole of the plan including nested stack
input:
- container: overcloud
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
get_flatten_data:
action: tripleo.parameters.get_flatten container=<% $.container %>
on-success: get_deprecated_params
on-error: set_status_failed_get_flatten_data
publish:
user_params: <% task().result.environment_parameters %>
plan_params: <% task().result.heat_resource_tree.parameters.keys() %>
parameter_groups: <% task().result.heat_resource_tree.resources.values().where( $.get('parameter_groups') ).select($.parameter_groups).flatten() %>
get_deprecated_params:
on-success: check_if_user_param_has_deprecated
publish:
deprecated_params: <% $.parameter_groups.where($.get('label') = 'deprecated').select($.parameters).flatten().distinct() %>
check_if_user_param_has_deprecated:
on-success: get_unused_params
publish:
deprecated_result: <% let(up => $.user_params) -> $.deprecated_params.select( dict('parameter' => $, 'deprecated' => true, 'user_defined' => $up.keys().contains($)) ) %>
# Get the list of parameters, which are defined by user via environment files's parameter_default, but not part of the plan definition
# It may be possible that the parameter will be used by a service, but the service is not part of the plan.
# In such cases, the parameter will be reported as unused, care should be take to understand whether it is really unused or not.
get_unused_params:
on-success: send_message
publish:
unused_params: <% let(plan_params => $.plan_params) -> $.user_params.keys().where( not $plan_params.contains($) ) %>
set_status_failed_get_flatten_data:
on-success: send_message
publish:
status: FAILED
message: <% task(get_flatten_data).result %>
send_message:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.get_deprecated_parameters
payload:
status: <% $.get('status', 'SUCCESS') %>
message: <% $.get('message', '') %>
execution: <% execution() %>
deprecated: <% $.get('deprecated_result', []) %>
unused: <% $.get('unused_params', []) %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
publish_ui_logs_to_swift:
description: >
This workflow drains a zaqar queue, and publish its messages into a log
file in swift. This workflow is called by cron trigger.
input:
- queue_name: tripleo
- logging_queue_name: tripleo-ui-logging
- logging_container: tripleo-ui-logs
tags:
- tripleo-common-managed
tasks:
get_messages:
action: zaqar.queue_messages
on-success: format_messages
on-error: get_messages_set_status_failed
input:
queue_name: <% $.logging_queue_name %>
publish:
messages: <% task().result %>
format_messages:
action: tripleo.logging_to_swift.format_messages
on-success: upload_to_swift
input:
messages: <% $.messages %>
publish:
messages: <% task().result %>
upload_to_swift:
action: tripleo.logging_to_swift.publish_ui_log_to_swift
on-success: set_status_success
on-error: upload_to_swift_set_status_failed
input:
logging_data: <% $.messages %>
logging_container: <% $.logging_container %>
set_status_success:
on-success: notify_zaqar
publish:
status: SUCCESS
message: <% task(upload_to_swift).result %>
upload_to_swift_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(upload_to_swift).result %>
get_messages_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(get_messages).result %>
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.publish_ui_logs_to_swift
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
download_logs:
description: Creates a tarball with logging data
input:
- queue_name: tripleo
- logging_container: "tripleo-ui-logs"
- downloads_container: "tripleo-ui-logs-downloads"
- delete_after: 3600
tags:
- tripleo-common-managed
tasks:
publish_logs:
workflow: tripleo.plan_management.v1.publish_ui_logs_to_swift
on-success: prepare_log_download
on-error: publish_logs_set_status_failed
prepare_log_download:
action: tripleo.logging_to_swift.prepare_log_download
input:
logging_container: <% $.logging_container %>
downloads_container: <% $.downloads_container %>
delete_after: <% $.delete_after %>
on-success: create_tempurl
on-error: download_logs_set_status_failed
publish:
filename: <% task().result %>
create_tempurl:
action: tripleo.swift.tempurl
on-success: set_status_success
on-error: create_tempurl_set_status_failed
input:
container: <% $.downloads_container %>
obj: <% $.filename %>
valid: 3600
publish:
tempurl: <% task().result %>
set_status_success:
on-success: notify_zaqar
publish:
status: SUCCESS
message: <% task(create_tempurl).result %>
tempurl: <% task(create_tempurl).result %>
publish_logs_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(publish_logs).result %>
download_logs_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(prepare_log_download).result %>
create_tempurl_set_status_failed:
on-success: notify_zaqar
publish:
status: FAILED
message: <% task(create_tempurl).result %>
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.download_logs
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
tempurl: <% $.get('tempurl', '') %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
list_roles:
description: Retrieve the roles_data.yaml and return a usable object
input:
- container: overcloud
- roles_data_file: 'roles_data.yaml'
- queue_name: tripleo
output:
roles_data: <% $.roles_data %>
tags:
- tripleo-common-managed
tasks:
get_roles_data:
action: swift.get_object
input:
container: <% $.container %>
obj: <% $.roles_data_file %>
publish:
roles_data: <% yaml_parse(task().result.last()) %>
status: SUCCESS
on-success: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
on-error: notify_zaqar
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.list_roles
payload:
status: <% $.status %>
roles_data: <% $.get('roles_data', {}) %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
list_available_networks:
input:
- container
- queue_name: tripleo
output:
available_networks: <% $.available_networks %>
tags:
- tripleo-common-managed
tasks:
get_network_file_names:
action: swift.get_container
input:
container: <% $.container %>
publish:
network_names: <% task().result[1].where($.name.startsWith('networks/')).where($.name.endsWith('.yaml')).name %>
on-success: get_network_files
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
get_network_files:
with-items: network_name in <% $.network_names %>
action: swift.get_object
on-success: transform_output
on-error: notify_zaqar
input:
container: <% $.container %>
obj: <% $.network_name %>
publish:
status: SUCCESS
available_yaml_networks: <% task().result.select($[1]) %>
publish-on-error:
status: FAILED
message: <% task().result %>
transform_output:
publish:
status: SUCCESS
available_networks: <% yaml_parse($.available_yaml_networks.join("\n")) %>
publish-on-error:
status: FAILED
message: <% task().result %>
on-complete: notify_zaqar
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.list_available_networks
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
available_networks: <% $.get('available_networks', []) %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
list_networks:
input:
- container: 'overcloud'
- network_data_file: 'network_data.yaml'
- queue_name: tripleo
output:
network_data: <% $.network_data %>
tags:
- tripleo-common-managed
tasks:
get_networks:
action: swift.get_object
input:
container: <% $.container %>
obj: <% $.network_data_file %>
on-success: notify_zaqar
publish:
network_data: <% yaml_parse(task().result.last()) %>
status: SUCCESS
message: <% task().result %>
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
notify_zaqar:
action: zaqar.queue_post
retry: count=5 delay=1
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.list_networks
payload:
status: <% $.status %>
network_data: <% $.get('network_data', {}) %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
validate_network_files:
description: Validate network files exist
input:
- container: overcloud
- network_data
- queue_name: tripleo
output:
network_data: <% $.network_data %>
tags:
- tripleo-common-managed
tasks:
get_network_names:
publish:
network_names_lower: <% $.network_data.where($.containsKey('name_lower')).name_lower %>
network_names: <% $.network_data.where(not $.containsKey('name_lower')).name %>
on-success: validate_networks
validate_networks:
with-items: network in <% $.network_names_lower.concat($.network_names) %>
action: swift.head_object
input:
container: <% $.container %>
obj: network/<% $.network.toLower() %>.yaml
publish:
status: SUCCESS
message: <% task().result %>
on-success: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
notify_zaqar:
action: zaqar.queue_post
retry: count=5 delay=1
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.validate_network_files
payload:
status: <% $.status %>
message: <% $.message %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
validate_networks:
description: Validate network files were generated properly and exist
input:
- container: 'overcloud'
- network_data_file: 'network_data.yaml'
- queue_name: tripleo
output:
network_data: <% $.network_data %>
tags:
- tripleo-common-managed
tasks:
get_network_data:
workflow: list_networks
input:
container: <% $.container %>
network_data_file: <% $.network_data_file %>
queue_name: <% $.queue_name %>
publish:
network_data: <% task().result.network_data %>
on-success: validate_networks
publish-on-error:
status: FAILED
message: <% task().result %>
on-error:
notify_zaqar
validate_networks:
workflow: validate_network_files
input:
container: <% $.container %>
network_data: <% $.network_data %>
queue_name: <% $.queue_name %>
publish:
status: SUCCESS
message: <% task().result %>
on-success: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
on-error: notify_zaqar
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.validate_networks
payload:
status: <% $.status %>
network_data: <% $.get('network_data', {}) %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
validate_roles:
description: Vaildate roles data exists and is parsable
input:
- container: overcloud
- roles_data_file: 'roles_data.yaml'
- queue_name: tripleo
output:
roles_data: <% $.roles_data %>
tags:
- tripleo-common-managed
tasks:
get_roles_data:
workflow: list_roles
input:
container: <% $.container %>
roles_data_file: <% $.roles_data_file %>
queue_name: <% $.queue_name %>
publish:
roles_data: <% task().result.roles_data %>
status: SUCCESS
on-success: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
on-error:
notify_zaqar
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.validate_networks
payload:
status: <% $.status %>
roles_data: <% $.get('roles_data', '') %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
_validate_networks_from_roles:
description: Internal workflow for validating a network exists from a role
input:
- defined_networks
- networks_in_roles
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
validate_network_in_network_data:
publish:
networks_found: <% $.networks_in_roles.toSet().intersect($.defined_networks.toSet()) %>
networks_not_found: <% $.networks_in_roles.toSet().difference($.defined_networks.toSet()) %>
on-success:
- network_not_found: <% $.networks_not_found %>
- notify_zaqar: <% not $.networks_not_found %>
network_not_found:
publish:
message: <% "Some networks in roles are not defined, {0}".format($.networks_not_found.join(', ')) %>
status: FAILED
on-success: notify_zaqar
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1._validate_networks_from_role
payload:
status: <% $.get('status', 'SUCCESS') %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
validate_roles_and_networks:
description: Vaidate that roles and network data are valid
input:
- container: overcloud
- roles_data_file: 'roles_data.yaml'
- network_data_file: 'network_data.yaml'
- queue_name: tripleo
output:
roles_data: <% $.roles_data %>
network_data: <% $.network_data %>
tags:
- tripleo-common-managed
tasks:
validate_network_data:
workflow: validate_networks
input:
container: <% $.container %>
network_data_file: <% $.network_data_file %>
queue_name: <% $.queue_name %>
publish:
network_data: <% task().result.network_data %>
on-success: validate_roles_data
publish-on-error:
status: FAILED
message: <% task().result %>
on-error: notify_zaqar
validate_roles_data:
workflow: validate_roles
input:
container: <% $.container %>
roles_data_file: <% $.roles_data_file %>
queue_name: <% $.queue_name %>
publish:
roles_data: <% task().result.roles_data %>
role_networks_data: <% task().result.roles_data.networks %>
networks_in_roles: <% task().result.roles_data.networks.flatten().distinct() %>
on-success: validate_roles_and_networks
publish-on-error:
status: FAILED
message: <% task().result %>
on-error: notify_zaqar
validate_roles_and_networks:
workflow: _validate_networks_from_roles
input:
defined_networks: <% $.network_data.name %>
networks_in_roles: <% $.networks_in_roles %>
queue_name: <% $.queue_name %>
publish:
status: SUCCESS
on-success: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result.message %>
on-error: notify_zaqar
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.validate_roles_and_networks
payload:
status: <% $.status %>
roles_data: <% $.get('roles_data', {}) %>
network_data: <% $.get('network_data', {}) %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
list_available_roles:
input:
- container: overcloud
- queue_name: tripleo
output:
available_roles: <% $.available_roles %>
tags:
- tripleo-common-managed
tasks:
get_role_file_names:
action: swift.get_container
input:
container: <% $.container %>
publish:
role_names: <% task().result[1].where($.name.startsWith('roles/')).where($.name.endsWith('.yaml')).name %>
on-success: get_role_files
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
get_role_files:
with-items: role_name in <% $.role_names %>
action: swift.get_object
on-success: transform_output
on-error: notify_zaqar
input:
container: <% $.container %>
obj: <% $.role_name %>
publish:
status: SUCCESS
available_yaml_roles: <% task().result.select($[1]) %>
publish-on-error:
status: FAILED
message: <% task().result %>
transform_output:
publish:
status: SUCCESS
available_roles: <% yaml_parse($.available_yaml_roles.join("\n")) %>
publish-on-error:
status: FAILED
message: <% task().result %>
on-complete: notify_zaqar
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.list_available_roles
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
available_roles: <% $.get('available_roles', []) %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
update_roles:
description: >
takes data in json format validates its contents and persists them in
roles_data.yaml, after successful update, templates are regenerated.
input:
- container
- roles
- roles_data_file: 'roles_data.yaml'
- replace_all: false
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
get_available_roles:
workflow: list_available_roles
publish:
available_roles: <% task().result.available_roles %>
on-success: validate_input
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
validate_input:
description: >
validate the format of input (verify that each role in input has the
required attributes set. check README in roles directory in t-h-t),
validate that roles in input exist in roles directory in t-h-t
action: tripleo.plan.validate_roles
input:
container: <% $.container %>
roles: <% $.roles %>
available_roles: <% $.available_roles %>
on-success: get_network_data
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
get_network_data:
workflow: list_networks
input:
container: <% $.container %>
queue_name: <% $.queue_name %>
publish:
network_data: <% task().result.network_data %>
on-success: validate_network_names
publish-on-error:
status: FAILED
message: <% task().result %>
on-error: notify_zaqar
validate_network_names:
description: >
validate that Network names assigned to Role exist in
network-data.yaml object in Swift container
workflow: _validate_networks_from_roles
input:
container: <% $.container %>
defined_networks: <% $.network_data.name %>
networks_in_roles: <% $.roles.networks.flatten().distinct() %>
queue_name: <% $.queue_name %>
on-success: get_current_roles
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result.message %>
get_current_roles:
workflow: list_roles
input:
container: <% $.container %>
roles_data_file: <% $.roles_data_file %>
queue_name: <% $.queue_name %>
publish:
current_roles: <% task().result.roles_data %>
on-success: update_roles_data
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
update_roles_data:
description: >
update roles_data.yaml object in Swift with roles from workflow input
action: tripleo.plan.update_roles
input:
container: <% $.container %>
roles: <% $.roles %>
current_roles: <% $.current_roles %>
replace_all: <% $.replace_all %>
publish:
updated_roles_data: <% task().result.roles %>
on-success: update_roles_data_in_swift
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
update_roles_data_in_swift:
description: >
update roles_data.yaml object in Swift with data from workflow input
action: swift.put_object
input:
container: <% $.container %>
obj: <% $.roles_data_file %>
contents: <% yaml_dump($.updated_roles_data) %>
on-success: regenerate_templates
publish-on-error:
status: FAILED
message: <% task().result %>
on-error: notify_zaqar
regenerate_templates:
action: tripleo.templates.process container=<% $.container %>
on-success: get_updated_roles
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
get_updated_roles:
workflow: list_roles
input:
container: <% $.container %>
roles_data_file: <% $.roles_data_file %>
publish:
updated_roles: <% task().result.roles_data %>
status: SUCCESS
on-complete: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.roles.v1.update_roles
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
updated_roles: <% $.get('updated_roles', []) %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
select_roles:
description: >
takes a list of role names as input and populates roles_data.yaml in
container in Swift with respective roles from 'roles directory'
input:
- container
- role_names
- roles_data_file: 'roles_data.yaml'
- replace_all: true
- queue_name: tripleo
tags:
- tripleo-common-managed
tasks:
get_available_roles:
workflow: list_available_roles
input:
container: <% $.container %>
queue_name: <% $.queue_name %>
publish:
available_roles: <% task().result.available_roles %>
on-success: get_current_roles
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
get_current_roles:
workflow: list_roles
input:
container: <% $.container %>
roles_data_file: <% $.roles_data_file %>
queue_name: <% $.queue_name %>
publish:
current_roles: <% task().result.roles_data %>
on-success: gather_roles
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
gather_roles:
description: >
for each role name from the input, check if it exists in
roles_data.yaml, if yes, use that role definition, if not, get the
role definition from roles directory. Use the gathered roles
definitions as input to updateRolesWorkflow - this ensures
configuration of the roles which are already in roles_data.yaml
will not get overridden by data from roles directory
action: tripleo.plan.gather_roles
input:
role_names: <% $.role_names %>
current_roles: <% $.current_roles %>
available_roles: <% $.available_roles %>
publish:
gathered_roles: <% task().result.gathered_roles %>
on-success: call_update_roles_workflow
on-error: notify_zaqar
publish-on-error:
status: FAILED
message: <% task().result %>
call_update_roles_workflow:
workflow: update_roles
input:
container: <% $.container %>
roles: <% $.gathered_roles %>
roles_data_file: <% $.roles_data_file %>
replace_all: <% $.replace_all %>
queue_name: <% $.queue_name %>
on-complete: notify_zaqar
publish:
selected_roles: <% task().result.updated_roles %>
status: SUCCESS
publish-on-error:
status: FAILED
message: <% task().result %>
notify_zaqar:
action: zaqar.queue_post
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.plan_management.v1.select_roles
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
selected_roles: <% $.get('selected_roles', []) %>
on-success:
- fail: <% $.get('status') = "FAILED" %>