Triggering job template in Ansible Tower from ManageIQ button


#1

Hi all,

I am trying to implement this:

I have gotten as far as setting up Tower 3.0.2, it integrates perfectly with CFME 4.1, and I can pull the inventory across now. I’ve created the Deploy PostgreSQL job template suggested in the blog and I can deploy it manually from the CFME interface.

So the final step is to integrate it with the CFME UI, and I’ve been trying to create a button as described in the blog post. I have done so, but when I click on the button the job doesn’t get deployed, and I see the following in evm.log:

[----] I, [2016-10-14T16:02:16.034835 #3285:46198c] INFO – : Q-task_id([resource_action_106]) <AEMethod [/ManageIQ/ConfigurationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansibl
e_job]> Starting
[----] E, [2016-10-14T16:02:16.482980 #3285:105b0f8] ERROR – : Q-task_id([resource_action_106]) The following error occurred during method evaluation:
[----] E, [2016-10-14T16:02:16.483503 #3285:105b0f8] ERROR – : Q-task_id([resource_action_106]) RuntimeError: Job Template not specified
[----] E, [2016-10-14T16:02:16.484363 #3285:105b0f8] ERROR – : Q-task_id([resource_action_106]) <code: raise “Job Template not specified”>:70:in job_template' <code: run(job_template, target)>:18:inmain’
[----] E, [2016-10-14T16:02:16.494693 #3285:1050324] ERROR – : Q-task_id([resource_action_106]) Method STDERR: <code: raise “Job Template not specified”>:70:in job_template': Job Template not sp ecified (RuntimeError) [----] E, [2016-10-14T16:02:16.495582 #3285:1050324] ERROR -- : Q-task_id([resource_action_106]) <AutomationEngine> Method STDERR: from <code: run(job_template, target)>:18:inmain’
[----] E, [2016-10-14T16:02:16.495675 #3285:1050324] ERROR – : Q-task_id([resource_action_106]) Method STDERR: from <code: LaunchAnsibleJob.new($evm).main>:106:in `’
[----] I, [2016-10-14T16:02:16.513160 #3285:46198c] INFO – : Q-task_id([resource_action_106]) <AEMethod [/ManageIQ/ConfigurationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansibl
e_job]> Ending
[----] E, [2016-10-14T16:02:16.513639 #3285:46198c] ERROR – : Q-task_id([resource_action_106]) State= running raised exception: <Method exited with rc=Unknown RC: [1]>
[----] W, [2016-10-14T16:02:16.513774 #3285:46198c] WARN – : Q-task_id([resource_action_106]) Error in State=[Launch]
[----] I, [2016-10-14T16:02:16.514020 #3285:46198c] INFO – : Q-task_id([resource_action_106]) Followed Relationship [miqaedb:/ConfigurationManagement/AnsibleTower/Operations/StateMachines/Job/d
efault#create]

My hunch is that the specification of “job_template_name” in the button definition is incorrect, even though this is featured in the blog article - as you can see the code is looking for “job_template” and not “job_template_name”.

I tried changing the attribute to be called “job_template” but then I see the following (still in error state):

[----] I, [2016-10-14T16:05:55.311827 #3285:46198c] INFO – : Q-task_id([resource_action_106]) <AEMethod [/ManageIQ/ConfigurationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job]> Starting
[----] E, [2016-10-14T16:05:55.728022 #3285:82cf08] ERROR – : Q-task_id([resource_action_106]) The following error occurred during method evaluation:
[----] E, [2016-10-14T16:05:55.728633 #3285:82cf08] ERROR – : Q-task_id([resource_action_106]) NoMethodError: undefined method name' for "Deploy PostgreSQL":String [----] E, [2016-10-14T16:05:55.729507 #3285:82cf08] ERROR -- : Q-task_id([resource_action_106]) <AutomationEngine> <AEMethod launch_ansible_job> <code: @handle.log(:info, "Processing Job Template #{job_template.name}")>:93:inrun’
<code: run(job_template, target)>:18:in main' [----] E, [2016-10-14T16:05:55.731657 #3285:82baa4] ERROR -- : Q-task_id([resource_action_106]) <AutomationEngine> Method STDERR: <code: @handle.log(:info, "Processing Job Template #{job_template.name}")>:93:inrun’: undefined method name' for "Deploy PostgreSQL":String (NoMethodError) [----] E, [2016-10-14T16:05:55.731810 #3285:82baa4] ERROR -- : Q-task_id([resource_action_106]) <AutomationEngine> Method STDERR: from <code: run(job_template, target)>:18:inmain’
[----] E, [2016-10-14T16:05:55.731926 #3285:82baa4] ERROR – : Q-task_id([resource_action_106]) Method STDERR: from <code: LaunchAnsibleJob.new($evm).main>:106:in `’
[----] I, [2016-10-14T16:05:55.757988 #3285:46198c] INFO – : Q-task_id([resource_action_106]) <AEMethod [/ManageIQ/ConfigurationManagement/AnsibleTower/Operations/StateMachines/Job/launch_ansible_job]> Ending
[----] E, [2016-10-14T16:05:55.758395 #3285:46198c] ERROR – : Q-task_id([resource_action_106]) State= running raised exception: <Method exited with rc=Unknown RC: [1]>
[----] W, [2016-10-14T16:05:55.758545 #3285:46198c] WARN – : Q-task_id([resource_action_106]) Error in State=[Launch]
[----] I, [2016-10-14T16:05:55.758873 #3285:46198c] INFO – : Q-task_id([resource_action_106]) Followed Relationship [miqaedb:/ConfigurationManagement/AnsibleTower/Operations/StateMachines/Job/default#create]

So now we’re looking for “job_template.name” - I tried setting that in the GUI but to no avail. I’ve read the forum post that references this new capability and it also uses “job_template_name” so I fear I must be doing something wrong - however I can’t see what.

Can anybody help?

Thanks in advance!

James


#2

@gmccullough can you review this question from @quruj and forward to a SME if necessary.


#3

@mkanoor Can you help out @quruj with this issue?


#4

Hello,
The Automate Method looks for job_template in different forms

  • job_template (object)
  • job_template_id (id)
  • job_template_name (name)

if it doesn’t find the job template using any of the above attributes it raises the error
"job template not specified"

It seems like the user selected job template is not being passed into Automate.

How are you binding the selected job to an attribute. You can also check the automation.log for incoming request and see what parameters are being passed in.


#5

Hi everyone,

Thanks so much for all your help and advice - I now have the button working as desired and passing jobs across to Ansible Tower.

I am unclear what went wrong - on a hunch I copied and pasted the “job_template_name” from the error message in the logs into the button definition and everything started working. Although I didn’t spot it I can only conclude there must have been a typo somewhere that I didn’t see.

This has enabled a demo for 25 potential new customers for CloudForms tonight so I am very grateful for everyone’s quick responses and help!

James


#6

There was an error submitting this request: Couldn’t find Vm with ‘id’=1000000000013 [WHERE “vms”.“type” IN (‘Vm’, ‘ManageIQ::Providers::CloudManager::Vm’, ‘ManageIQ::Providers::InfraManager::Vm’, ‘VmServer’, ‘ManageIQ::Providers::Amazon::CloudManager::Vm’, ‘ManageIQ::Providers::Google::CloudManager::Vm’, ‘ManageIQ::Providers::Openstack::CloudManager::Vm’, ‘ManageIQ::Providers::Azure::CloudManager::Vm’, ‘ManageIQ::Providers::Vmware::CloudManager::Vm’, ‘ManageIQ::Providers::Microsoft::InfraManager::Vm’, ‘ManageIQ::Providers::Redhat::InfraManager::Vm’, ‘VmXen’, ‘ManageIQ::Providers::Vmware::InfraManager::Vm’) AND “vms”.“template” = $1]

I am trying to run ansible playbook from cloudform button.But I am getting this error.
Please help.
Playbook-“sample playbook run on localhost”

Please help


#7

@ishagpt can you open a new issue. You’ll find it’ll get better traction that way. Adding to this existing issue can cause confusion.


#8

@ishagpt additionally,…on the new issue you create, please add what version of ManageIQ you’re using.