Bug 1417309

Summary: [RFE] Allow for Ansible_Tower_Job to launch job templates even if no VM is in context
Product: Red Hat CloudForms Management Engine Reporter: Jerome Marc <jmarc>
Component: AutomateAssignee: John Hardy <jhardy>
Status: CLOSED WONTFIX QA Contact: Nandini Chandra <nachandr>
Severity: high Docs Contact:
Priority: high    
Version: 5.7.0CC: jhardy, jocarter, mkanoor, niroy, obarenbo, tfitzger
Target Milestone: GAKeywords: FutureFeature
Target Release: cfme-future   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: tower
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-07 16:15:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jerome Marc 2017-01-27 22:58:00 UTC
Description of problem:
I want to launch Ansible Job Templates on objects where a VM is not in context. The current implementation of Ansible_Tower_Job requires a VM in context in wait_for_ip. In my use case, I want to add custom buttons on Hosts or Providers (e.g. to manage AWS Services using Ansible Job Templates). The current implementation does not allow me to launch the Ansible Job Template for any other objects than VMs/Services.

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

How reproducible:
Always

Steps to Reproduce:
1. Have an Ansible Job Template to perform generic operations
2. Create a custom button on a Provider and associate the job template
3. Launch the Job Template by clicking on the button on the provider

Actual results:
The job template launch fails as there is no VM in context on a provider

Expected results:
The job template launch should work

Additional info:
My current workaround (there is surely something nicer) is to modify / ManageIQ / ConfigurationManagement / AnsibleTower / Operations / StateMachines / Job / wait_for_ip to provide my ansible-tower VM as vm object in the vm_not_found method:

  def vm_not_found
    @handle.log(:info, "Use Ansible Tower VM (BZ workaround) to launch Ansible Job Template")
    vm = $evm.vmdb('vm').find_by_name('ansible-tower')
    if vm
      @handle.root['ae_result'] = 'ok'
      @handle.log(:info, "VM found: #{vm.name}")
    else
      @handle.root['ae_result'] = 'error'
      @handle.log(:error, "VM not found")
    end
  end