Playbook Service Provision & Retirement State Machines
Last updated
Last updated
An Ansible playbook service has a new type of Active Record object (ServiceAnsiblePlaybook) and a corresponding auto-generated service model object (MiqAeServiceServiceAnsiblePlaybook). A new simplified service lifecycle state machine class had been developed to handle Ansible playbook services using the features and methods of the ServiceAnsiblePlaybook object.
The new state machine instances still reference many of the original service lifecycle instance and methods under /Service/Provisioning and /Service/Retirement in the automate datastore, but several new methods are included to handle the ServiceAnsiblePlaybook object-specific processing (see screenshot New GenericLifecycle Class)
There is a single generic service provisioning state machine.
The provision state machine runs the provisioning playbook and creates a new service in the Active Services folder of the Services accordion in Services -> My Services in the WebUI.
There are several service retirement state machines split into two categories: basic resource - for services that don't have a retirement playbook - and advanced resource, for services that do. A retired service is moved into the Retired Services folder of the Services accordion in Services -> My Services in the WebUI.
The basic resource retirement state machines are used if the service catalog item definition doesn't specify a retirement playbook to run. The selection of state machine is automatic and depends on the configured value for the Remove Resources? dropdown in the Retirement tab of the service definition (see screenshot Remove Resources? Dropdown)
The state machines are as follows:
The retire_basic_resource_none state machine is the simplest service retirement state machine. It retires the service, and leaves untouched any service resources such as VMs.
The retire_basic_resource state machine retires the service, but also attempts to retire any VMs under this top level service.
The advanced resource retirement state machines are used if the service catalog item definition specifies a retirement playbook to be run. The selection of state machine is automatic, once again depending on the configured value for the Remove Resources? dropdown.
The state machines are as follows:
The retire_advanced_resource_none state machine retires the service and runs the service retirement playbook, but leaves untouched any service resources such as VMs.
The retire_advanced_resource_pre state machine retires the service and any VMs under this top level service, and then finally runs the service retirement playbook.
The retire_advanced_resource_post state machine retires the service, runs the service retirement playbook, and then finally attempts to retire any VMs under this top level service.
Note
Any dynamic playbook variables or hosts used for the service provision - for example passed from a service dialog - are not available when the retirement playbooks are run. The static values configured in the Retirement tab of the service definition are used to run the retirement playbook.
This chapter has described the new state machines that handle the provisioning and retirement of embedded Ansible playbook services. They can be cloned to a user-defined domain and edited to extend functionality, if required.