Bug 1658172 - [RFE] launch_ansible_job fails to launch Ansible Tower workflow jobs
Summary: [RFE] launch_ansible_job fails to launch Ansible Tower workflow jobs
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.10.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.11.0
Assignee: Lucy Fu
QA Contact: Nandini Chandra
Red Hat CloudForms Documentation
URL:
Whiteboard:
Depends On:
Blocks: 1763859
TreeView+ depends on / blocked
 
Reported: 2018-12-11 12:40 UTC by Peter McGowan
Modified: 2019-12-13 14:54 UTC (History)
10 users (show)

Fixed In Version: 5.11.0.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1763859 (view as bug list)
Environment:
Last Closed: 2019-12-13 14:54:21 UTC
Category: ---
Cloudforms Team: CFME Core
Target Upstream Version:


Attachments (Terms of Use)
screen shot of Ansible workflow simulation (38.74 KB, image/png)
2019-09-03 16:45 UTC, Nandini Chandra
no flags Details

Description Peter McGowan 2018-12-11 12:40:58 UTC
Description of problem:
launch_ansible_job fails to launch Ansible Tower workflow jobs


Version-Release number of selected component (if applicable):
5.10.0.28

How reproducible:
Every time


Steps to Reproduce:
In a Tower server configured as a CloudForms Tower provider:
1. Create an Ansible Tower workflow
2. In CloudForms Automate, try to call the workflow job using /AutomationManagement/AnsibleTower/Operations/StateMachines/Job/default

Actual results:
The job fails with the error:

[----] E, [2018-12-11T04:06:07.830535 #5501:49fc28] ERROR -- : Q-task_id([resource_action_99000000000025]) <AEMethod launch_ansible_job> The 
following error occurred during method evaluation:
[----] E, [2018-12-11T04:06:07.831232 #5501:49fc28] ERROR -- : Q-task_id([resource_action_99000000000025]) <AEMethod launch_ansible_job>   Ru
ntimeError: Job Template not specified
[----] E, [2018-12-11T04:06:07.833370 #5501:49fc28] ERROR -- : Q-task_id([resource_action_99000000000025]) <AEMethod launch_ansible_job>   /M
anageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job:81:in `job_template'
/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job:26:in `main'

Expected results:

The job should run

Additional info:

It looks like launch_ansible_job has a constant: "SCRIPT_CLASS = 'ManageIQ_Providers_AnsibleTower_AutomationManager_ConfigurationScript'.freeze" which is incorrect for a workflow as it's now a ManageIQ_Providers_AnsibleTower_AutomationManager_WorkflowJob object.

It also has a constant: "JOB_CLASS = 'ManageIQ_Providers_AnsibleTower_AutomationManager_Job'.freeze" defined, however a workflow job object is a ManageIQ_Providers_AnsibleTower_AutomationManager_WorkflowJob object.

Comment 2 Peter McGowan 2018-12-11 12:46:13 UTC
Sorry I was incorrect, ManageIQ_Providers_AnsibleTower_AutomationManager_ConfigurationScript is now a ManageIQ_Providers_AnsibleTower_AutomationManager_ConfigurationWorkflow object I believe for a workflow

Comment 3 Lucy Fu 2018-12-11 14:48:59 UTC
Peter,

Regarding your step 2 - In CloudForms Automate, try to call the workflow job using /AutomationManagement/AnsibleTower/Operations/StateMachines/Job/default

What does it mean? How did you do that?
Does it work if you run it as a service?

Thanks.

Comment 4 Peter McGowan 2018-12-11 15:08:28 UTC
Hi Lucy

You can run a playbook through /AutomationManagement/AnsibleTower/Operations/StateMachines/Job/default by calling /System/Request/ansible_tower_job and passing a parameter pair of:

job_template_name  <template_name>

A service works fine, but then a service isn't calling this method.

Thanks

Comment 8 CFME Bot 2019-04-24 19:31:17 UTC
New commit detected on ManageIQ/manageiq-content/master:

https://github.com/ManageIQ/manageiq-content/commit/c699cd8fdbb39a930c4f21747f6e10dd40ff801e
commit c699cd8fdbb39a930c4f21747f6e10dd40ff801e
Author:     Lucy Fu <lufu@redhat.com>
AuthorDate: Wed Dec 19 10:42:17 2018 -0500
Commit:     Lucy Fu <lufu@redhat.com>
CommitDate: Wed Dec 19 10:42:17 2018 -0500

    Changes to launch_ansible_job to support Ansible Tower workflow template.

    https://bugzilla.redhat.com/show_bug.cgi?id=1658172

 content/automate/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job.class/__methods__/launch_ansible_job.rb | 5 +-
 content/automate/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job.class/__methods__/wait_for_completion.rb | 2 +-
 spec/content/automate/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job.class/__methods__/launch_ansible_job_spec.rb | 87 +-
 3 files changed, 71 insertions(+), 23 deletions(-)

Comment 9 CFME Bot 2019-04-24 19:45:35 UTC
New commit detected on ManageIQ/manageiq-automation_engine/master:

https://github.com/ManageIQ/manageiq-automation_engine/commit/f828fe218a846e5b72e0d22885ee8e73c7d329dd
commit f828fe218a846e5b72e0d22885ee8e73c7d329dd
Author:     Lucy Fu <lufu@redhat.com>
AuthorDate: Wed Dec 19 10:38:06 2018 -0500
Commit:     Lucy Fu <lufu@redhat.com>
CommitDate: Wed Dec 19 10:38:06 2018 -0500

    Add helper method #create_job for Ansible Tower Job/Workflow template.

    https://bugzilla.redhat.com/show_bug.cgi?id=1658172

 lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-ansible_tower-automation_manager-configuration_script.rb | 4 +
 lib/miq_automation_engine/service_models/miq_ae_service_manageiq-providers-ansible_tower-automation_manager-configuration_workflow.rb | 4 +
 spec/service_models/miq_ae_service_manageiq-providers-ansible_tower-automation_manager-configuration_script_spec.rb | 8 +
 spec/service_models/miq_ae_service_manageiq-providers-ansible_tower-automation_manager-configuration_workflow_spec.rb | 8 +
 4 files changed, 24 insertions(+)

Comment 11 Nandini Chandra 2019-08-30 22:43:27 UTC
Hi Pete/Lucy,

I ran an automation simulation of an Ansible workflow on a CFME 5.11.0.22 appliance.

Attached screen shot shows the simulation details.

The workflow was eventually successfully run on Ansible Tower.

Here is a snippet from automation.log. Do these steps verify this BZ ?

[----] I, [2019-08-30T18:31:06.298892 #8534:2b134a3c40b4]  INFO -- : Updated namespace [AutomationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job  ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines]
[----] I, [2019-08-30T18:31:06.306784 #8534:2b134a3c40b4]  INFO -- : Invoking [inline] method [/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job] with inputs [{}]
[----] I, [2019-08-30T18:31:06.308335 #8534:2b134a3c40b4]  INFO -- : <AEMethod [/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job]> Starting
[----] I, [2019-08-30T18:31:06.782415 #8534:2b134ecf43d8]  INFO -- : <AEMethod launch_ansible_job> Processing Job Template simulation-workflow
[----] I, [2019-08-30T18:31:06.787009 #8534:2b134ecf43d8]  INFO -- : <AEMethod launch_ansible_job> Job Arguments {:extra_vars=>{}, :limit=>"ansible-host1-dnd"}
[----] I, [2019-08-30T18:31:51.930881 #8534:2b134ecf43d8]  INFO -- : <AEMethod launch_ansible_job> Scheduled Job ID: 42 Ansible Job ID: 6709
[----] I, [2019-08-30T18:31:51.953239 #8534:2b134a3c40b4]  INFO -- : <AEMethod [/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job]> Ending

[----] I, [2019-08-30T18:31:51.953306 #8534:2b134a3c40b4]  INFO -- : Method exited with rc=MIQ_OK
[----] I, [2019-08-30T18:31:51.953707 #8534:2b134a3c40b4]  INFO -- : Processed State=[Launch] with Result=[ok]
[----] I, [2019-08-30T18:31:51.953771 #8534:2b134a3c40b4]  INFO -- : Processed State=[Launch]
[----] I, [2019-08-30T18:31:51.953927 #8534:2b134a3c40b4]  INFO -- : Next State=[WaitForCompletion]
[----] I, [2019-08-30T18:31:51.954141 #8534:2b134a3c40b4]  INFO -- : Processing State=[WaitForCompletion]
[----] I, [2019-08-30T18:31:52.236338 #8534:2b134a3c40b4]  INFO -- : Updated namespace [AutomationManagement/AnsibleTower/Operations/StateMachines/Job/wait_for_completion  ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines]

[----] I, [2019-08-30T18:31:52.243763 #8534:2b134a3c40b4]  INFO -- : Invoking [inline] method [/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/wait_for_completion] with inputs [{}]
[----] I, [2019-08-30T18:31:52.248144 #8534:2b134a3c40b4]  INFO -- : <AEMethod [/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/wait_for_completion]> Starting
[----] I, [2019-08-30T18:32:36.530112 #7741:2b1345b525c4]  INFO -- : User [admin] with current group ID [1] name [Tenant My Company access]
[----] I, [2019-08-30T18:32:36.532459 #7741:2b1345b525c4]  INFO -- : Instantiating [/System/Process/Event?EventStream%3A%3Aevent_stream=453&MiqServer%3A%3Amiq_server=1&User%3A%3Auser=1&event_id=453&event_stream_id=453&event_type=workflow_job_create&object_name=Event&vmdb_object_type=event_stream]
[----] I, [2019-08-30T18:32:36.549031 #7741:2b1345b525c4]  INFO -- : Updated namespace [/System/Process/Event?EventStream%3A%3Aevent_stream=453&MiqServer%3A%3Amiq_server=1&User%3A%3Auser=1&event_id=453&event_stream_id=453&event_type=workflow_job_create&object_name=Event&vmdb_object_type=event_stream  ManageIQ/System]

[----] I, [2019-08-30T18:32:36.563330 #7768:2b1345b525c4]  INFO -- : User [admin] with current group ID [1] name [Tenant My Company access]
[----] I, [2019-08-30T18:32:36.565727 #7768:2b1345b525c4]  INFO -- : Instantiating [/System/Process/Event?EventStream%3A%3Aevent_stream=454&MiqServer%3A%3Amiq_server=1&User%3A%3Auser=1&event_id=454&event_stream_id=454&event_type=job_create&object_name=Event&vmdb_object_type=event_stream]
[----] I, [2019-08-30T18:32:36.582873 #7768:2b1345b525c4]  INFO -- : Updated namespace [/System/Process/Event?EventStream%3A%3Aevent_stream=454&MiqServer%3A%3Amiq_server=1&User%3A%3Auser=1&event_id=454&event_stream_id=454&event_type=job_create&object_name=Event&vmdb_object_type=event_stream  ManageIQ/System]
[----] I, [2019-08-30T18:32:36.607586 #7741:2b1345b525c4]  INFO -- : Following Relationship [miqaedb:/System/Event/EmsEvent/ANSIBLETOWER/workflow_job_create#create]
[----] I, [2019-08-30T18:32:36.628390 #7741:2b1345b525c4]  INFO -- : Updated namespace [miqaedb:/System/Event/EmsEvent/ANSIBLETOWER/workflow_job_create#create  ManageIQ/System/Event/EmsEvent]
[----] I, [2019-08-30T18:32:36.639479 #7768:2b1345b525c4]  INFO -- : Following Relationship [miqaedb:/System/Event/EmsEvent/ANSIBLETOWER/job_create#create]
[----] I, [2019-08-30T18:32:36.661406 #7768:2b1345b525c4]  INFO -- : Updated namespace [miqaedb:/System/Event/EmsEvent/ANSIBLETOWER/job_create#create  ManageIQ/System/Event/EmsEvent]

[----] I, [2019-08-30T18:32:36.747767 #7741:2b1345b525c4]  INFO -- : Instance [/ManageIQ/System/Event/EmsEvent/ANSIBLETOWER/workflow_job_create] not found in MiqAeDatastore - trying [.missing]
[----] I, [2019-08-30T18:32:36.754852 #7741:2b1345b525c4]  INFO -- : Followed  Relationship [miqaedb:/System/Event/EmsEvent/ANSIBLETOWER/workflow_job_create#create]
[----] I, [2019-08-30T18:32:36.778913 #7768:2b1345b525c4]  INFO -- : Instance [/ManageIQ/System/Event/EmsEvent/ANSIBLETOWER/job_create] not found in MiqAeDatastore - trying [.missing]
[----] I, [2019-08-30T18:32:36.785537 #7768:2b1345b525c4]  INFO -- : Followed  Relationship [miqaedb:/System/Event/EmsEvent/ANSIBLETOWER/job_create#create]
[----] I, [2019-08-30T18:32:40.312492 #8534:2b134a3c40b4]  INFO -- : <AEMethod [/ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/wait_for_completion]> Ending
[----] I, [2019-08-30T18:32:40.312603 #8534:2b134a3c40b4]  INFO -- : Method exited with rc=MIQ_OK

[----] I, [2019-08-30T18:32:40.312909 #8534:2b134a3c40b4]  INFO -- : Processed State=[WaitForCompletion] with Result=[ok]
[----] I, [2019-08-30T18:32:40.312970 #8534:2b134a3c40b4]  INFO -- : Processed State=[WaitForCompletion]
[----] I, [2019-08-30T18:32:40.313104 #8534:2b134a3c40b4]  INFO -- : Next State=[]
[----] I, [2019-08-30T18:32:40.313184 #8534:2b134a3c40b4]  INFO -- : Followed  Relationship [miqaedb:/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/default#create]
[----] I, [2019-08-30T18:32:40.313563 #8534:2b134a3c40b4]  INFO -- : Followed  Relationship [miqaedb:/System/Request/ansible_tower_job#create]

Comment 12 Lucy Fu 2019-09-03 14:29:59 UTC
Nandini,

To test this BZ, create a custom button by calling /System/Request/ansible_tower_job and passing a parameter pair of:

job_template_name  <template_name>

Simulation works as well.

Comment 13 Nandini Chandra 2019-09-03 16:45:58 UTC
Created attachment 1611224 [details]
screen shot of Ansible workflow simulation

Comment 14 Nandini Chandra 2019-09-03 19:08:23 UTC
Verified in 5.11.0.22


Note You need to log in before you can comment on or make changes to this bug.