Minimize technical debt with orchestration actions
Clean up the dependencies a server leaves behind, and remove servers whose provisioning failed
7 minute read
An orchestration action runs at a trigger point, one of the many predefined places in CMP processes where custom code can run. Trigger points are grouped into categories on the Admin > Orchestration Actions page. If a trigger point invokes an action that requires additional inputs, provide defaults for that action in this context. The same underlying action can have different defaults when invoked from different trigger points.
Go to Admin > Orchestration Actions. The tree on the left lists every category and, under each, its trigger points, each with a count of the actions currently attached. Select a category to see all of its actions, or select a single trigger point to narrow the table to that one. The table lists each action’s name, type, trigger point, and whether it is enabled. When you scope the table to a single trigger point, the Trigger Point column is hidden, because the tree already shows which one you are looking at.
(opens full-size image in a new tab)
Selecting a single trigger point also reveals an add button named after that trigger point, such as Add Post-Delete Action. A new orchestration action must be attached to a trigger point, which is why the button stays hidden until you pick one. When the table is scoped to one trigger point, you can drag its rows to set the order in which the actions run.
(opens full-size image in a new tab)
Two trigger points, Pre-Provisioning Engine Server Creation and Pre-Power-on, appear only when at least one provision engine is configured. The Terraform Related category appears only when Terraform is in use.
| Category | Trigger points |
|---|---|
| Provision Server | Pre-Provision, Generated Hostname Overwrite, Validate Hostname, Pre-Create Resource, Pre-Provisioning Engine Server Creation, Pre-Power-on, Pre-Network Configuration, During Resource Provisioning, Post-Network Configuration, Network Verification, Post-Network Verification, Pre-Application Installation, Ansible Automation Configuration, Post-Provision |
| Delete Server | Pre-Delete, Post-Delete |
| Expire | Pre-Expire Server, Post-Expire Server |
| Server Modification | Pre-Server Modification, Post-Server Modification |
| Synchronize VMs from Resource Handlers | Pre Sync VMs, Post Sync VMs, Pre Server Refresh |
| Continuous Infrastructure Testing | Pre-CIT, Post-CIT |
| Install Applications with Configuration Manager | Pre-Install Applications, Post-Install Applications, Pre-Uninstall Applications, Post-Uninstall Applications |
| Delete Resource | Pre-Delete Resource, Post-Delete Resource |
| Power Related | Pre Power On, Post Power On, Pre Power Off, Post Power Off, Pre Reboot, Post Reboot |
| Order Related | Generated Resource Name Overwrite, Blueprint Validation, Server Tier Validation, Order Submitted for Approval, Order Submitted for Approval Notifications, Post-Order Denied, Post-Order Approval, Post-Order Execution, Post-Order Execution Notification |
| Group & Environment | Post Group Creation, Pre Group Modification, Post Group Modification, Post Environment Creation, Pre Environment Modification, Post Environment Modification |
| Terraform Related | Terraform Pre-Provision, Terraform Init, Terraform Plan, Terraform Apply, Terraform Post-Provision, Terraform Provision Failure, Terraform Provision Cleanup, Terraform Pre-Destroy, Terraform Destroy, Terraform Post-Destroy, Terraform Destroy Failure, Terraform Destroy Cleanup |
| Parameters | Parameter Change, Generated Parameter Options |
| Other | Pre-Job, Post-Job, Waiting for Config Manager Agent Checkin, SSO User Update, External Users Sync, Compute Server Rate, Validate IP Address, Validate Order Recipient |
An orchestration action can be set to continue on failure, which means that if the action fails, the rest of the job is unaffected. The job neither fails nor changes course. This is useful for actions that occasionally fail but whose failure does not prevent the job from completing successfully.
A few trigger points do not honor this setting, including the two trigger points in the Parameters category, as well as Generated Hostname Overwrite, Pre Server Refresh, and Compute Server Rate.
Actions can be executed at many points throughout the job flow. For each job type, actions are executed in the order listed below, where <job-type> represents the job being run:
Pre-Job and Post-Job are in the Other category rather than under a specific job type, because they apply to every job.
By default, post-job actions run regardless of the main job’s result, even if the main job fails. To run an action only when the job finished with particular statuses, edit the action at that trigger point and set the statuses it should run on.
The Provision Server job has trigger points that occur during the job, not just before and after it. Under Provision Server in the tree, the trigger points are listed in the order they are executed during a provision job.
The Order Related category covers validation, approval, and execution of orders. The trigger points used most often are:
The category also includes Generated Resource Name Overwrite, Blueprint Validation, Server Tier Validation, Post-Order Denied, and two notification trigger points: Order Submitted for Approval Notifications and Post-Order Execution Notification.
Form validation for blueprint orders without server tiers is handled at Blueprint Validation. For blueprints that require server-tier validation, use Server Tier Validation.
Order Submitted for Approval and Post-Order Approval are also used in custom order approval workflows. For more information about implementing your own approval workflow, see Special case plugins. To customize blueprint deployment specifically, see Blueprint actions.
The Group & Environment category contains six trigger points:
group and environment, respectively.group and environment, respectively.group and existing_group. Compare the two in the action; if the action returns a FAILURE status or raises an exception, the object is not saved. These actions do not run when many-to-many relationships on the group change, such as its parameters, only when the group itself is saved.environment and existing_environment. Compare the two in the action; if the action returns a FAILURE status or raises an exception, the object is not saved. These actions do not run when many-to-many relationships on the environment change, such as its parameters, only when the environment itself is saved.These trigger points do not respect the group and environment filters on actions.
Here is a sample Pre Group Modification plugin:
"""
This plug-in, to be run at the "Pre Group Modification" trigger point, prevents
any modification to groups that add "cheese" to their description.
"""
from common.methods import set_progress
def run(job, group=None, existing_group=None, *args, **kwargs):
if existing_group.description == group.description:
set_progress("No change in group description.")
return
# These messages will show up in CB's application.log
set_progress(f"Group's description was: {existing_group.description}")
set_progress(f"Group's description will be: {group.description}")
if "cheese" in group.description:
return ("FAILURE",
"Invalid group description",
"'cheese is not allowed in the group description.'")
The Parameters category contains two trigger points:
get_options_list method that returns either a list of option tuples or a dictionary containing both the options and the initial value. See Action input parameters, where the method has the same possible return values.Two trigger points in the Other category relate to users:
The way Terraform commands are invoked is exposed as Terraform orchestration actions, allowing administrators to customize both how Terraform is invoked and how the resulting resources are integrated with CMP. The Terraform Related category is shown only when Terraform is in use. See Terraform operations.
Clean up the dependencies a server leaves behind, and remove servers whose provisioning failed
Represent NAT on the IP addresses of servers that Cloud Management Platform (CMP) manages