Use the standard messaging in the fernet-key-rotate workbook

Update the fernet-key-rotate workbook to use the standard message sending
workflow. This workflow reduces the boilerplate that is copied between
workflows by defining the message structure, providing the retry logic
and ensuring the task on a "FAILED" message.

The workflow also offers optional persistence in Swift. If the plan name
is given to the workflow it will store the messages in a Swift container
named <plan_name>-messages.

Related-Bug: #1757372

Change-Id: I5087b777a24700c0d99c42db9ead64933674247b
This commit is contained in:
Dougal Matthews
2018-03-20 14:01:11 +00:00
parent 2f91f4c58e
commit 4c124f6559

View File

@@ -21,7 +21,7 @@ workflows:
rotate_keys:
action: tripleo.parameters.rotate_fernet_keys container=<% $.container %>
on-success: deploy_ssh_key
on-error: notify_zaqar
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
@@ -29,7 +29,7 @@ workflows:
deploy_ssh_key:
workflow: tripleo.validations.v1.copy_ssh_key
on-success: get_privkey
on-error: notify_zaqar
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
@@ -37,7 +37,7 @@ workflows:
get_privkey:
action: tripleo.validations.get_privkey
on-success: deploy_keys
on-error: notify_zaqar
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
@@ -56,25 +56,21 @@ workflows:
fernet_keys: <% task(rotate_keys).result %>
use_openstack_credentials: true
playbook: /usr/share/tripleo-common/playbooks/rotate-keys.yaml
on-success: notify_zaqar
on-success: send_message
publish:
status: SUCCESS
message: <% task().result %>
on-error: notify_zaqar
on-error: send_message
publish-on-error:
status: FAILED
message: <% task().result %>
notify_zaqar:
action: zaqar.queue_post
send_message:
workflow: tripleo.messaging.v1.send
input:
queue_name: <% $.queue_name %>
messages:
body:
type: tripleo.fernet_keys.v1.rotate_fernet_keys
payload:
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
type: <% execution().name %>
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
plan_name: <% $.container %>