External API Help

Hi,
I am hoping someone can point me in the correct direction. I am trying to create a variable, that would allow me to dynamically change it from the exposed API, while the job is running. The job will stay in an loop until the variable has been changed to contain the desired information. I have looked into object walking, and other articles… I am hoping I overlooked something.

As an example, I am using the Service Catalog to execute an Ansible Tower Job:
Than, under the preprovision method in StateMachines, I added @handle.root[“service_template_provision_task”].set_option(‘build_status’, ‘preparing’). Later, under the check_provisioned method, I added a status_vm = @handle.root[“service_template_provision_task”].get_option(‘build_status’).

Ansible Tower receives the connection information, “href”: “https://192.168.1.10/api/requests/205/request_tasks/204” and using this information I can run a GET to see my variable: {“options”: “build_status”: “preparing” }.

If I edit this:
{
“action”: “edit”,
“options”: {
“build_status”: “built”
}
}
Changes to:
“build_status”: “built”

However, with the job that is in the loop, I cant seem to locate where this is changed to print the updated variable. It does continue to print the old variable.

Thanks for the help!

Did you check out the manageiq_automate-role?

To change variables for an running Automate Task you need to change it in the automate_workspace

Thanks for the assistance. I believe the confusion is in my misunderstanding of how to use an automate task. I am hoping you can correct my thinking.Calling a Playbook Method from the VM Provision State Machine - Mastering Automation Addendum for CloudForms 4.6 and ManageIQ Gaprindashvili, made me think that I could edit an option. Even though it shows the example as an embedded Ansible, the method is what I am using externally, I am not sure when the data is refreshed in ManageIQ side.

I am using AWX as a provider, and when I launch an service catalog to one of the workflows in AWX it only passes this information:

manageiq:
X_MIQ_Group: user.Manageiq
api_token: 6921c19f44d4c652153644d225ee8a12
api_url: ‘192.168.1.1’
group: groups/23
request: requests/214
request_task: requests/214/request_tasks/213
service: services/212
user: users/6
manageiq_connection:
X_MIQ_Group: user.Manageiq
token: 6921c19f44d4c652153644d225ee8a12
url: ‘https://192.168.1.1

My thinking was:
Execute external AWX job → pause next step until variable has been updated via API (in case the job fails, this give us time to repair it vs the end user getting a failure message) → continue next steps.

hm… Never really used ansible much myself and never used AWX.

However you said, that the value is updated on the API? In that case you should be able to read the updated value like this

my_task_id = $evm.root[:service_template_provision_task].id
updated_task = $evm.vmdb(:service_template_provision_task).find_by(id: my_task_id)
new_status = updated_task.get_option('build_status')

or maybe even:
updated_task = $evm.root[:service_template_provision_task]
updated_task.reload
new_status = updated_task.get_option('build_status')