Retire Catalog Bundle resources


Hi, we have an catalog bundle with multiple resources

  1. create machine in Azure based on orchestration template
  2. Ansible tower job 1
  3. Ansible tower job 2

When we retire the service we also want to retire the ansible jobs (execute the ansible tower job again with another state=absent) . I already wrote so code to execute the ansible tower jobs with the state to absent. This is working ok.

What I am looking for is the place to execute that code. When I retire the service now I see all resources are retired one by one, but when it is an ansible resource I want my code to be executed. Can some point me where I should do this?




I have not implemented this myself but Peter’s book writes:

The RetireService instance calls the retire_service state machine method, which in turn calls the service object’s retire_service_resources method. This method calls the retire_now method of every VM comprising the service, to initiate their retirement. CheckServiceRetired retries the stage until all VMs are retired or deleted.

So the default state machine takes care only of the VMs.
The whole thing called from the /Service/Retirement/StateMachines/ServiceRetirement/Default state machine by default. I’d copy this with a new name (and specify it at the bundle retirement entry point according to the book), replace the RetireService instance with a custom one invoking a custom retire_service method where you can call your code.