Bug 1468193

Summary: [RFE] Retirement playbook for an Ansible playbook service runs on the incorrect host
Product: Red Hat CloudForms Management Engine Reporter: Peter McGowan <pmcgowan>
Component: AutomateAssignee: Greg McCullough <gmccullo>
Status: CLOSED WONTFIX QA Contact: Dave Johnson <dajohnso>
Severity: high Docs Contact:
Priority: high    
Version: 5.8.0CC: jhardy, kborup, lavenel, mfeifer, mkanoor, obarenbo, tfitzger
Target Milestone: GAKeywords: FutureFeature
Target Release: 5.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: ansible:retirement:playbook
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-12-18 14:33:11 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 Peter McGowan 2017-07-06 09:21:44 UTC
Description of problem:
An Ansible Playbook service template can be created that contains a retirement playbook. The service template contains a default 'hosts' element (this is a mandatory field that must be completed when the service catalog item is created). The service can however also use a service dialog that allows the 'hosts' field to be overriden at order time.

When the ordered service (in "My Services") is retired, the retirement playbook runs on the host defined in the service template, rather than the host specified in the service dialog that the provisioning playbook was run on.

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

How reproducible:
Every time


Steps to Reproduce:
1. Create a service of type Ansible playbook. In the 'Provisioning' tab, specify a suitable repository, playbook and machine credential. Leave the Cloud Type as '<choose>'.
2. In the 'Provisioning' tab, add the value 'localhost' to the 'Hosts' element.
3. In the 'Dialog' element, check 'Create New' and give a name for a new dialog
4. In the 'Retirement' tab, specify a suitable repository, playbook and machine credential. Leave the Cloud Type as '<choose>'.
5. In the 'Retirement' tab, add the value 'localhost' to the 'Hosts' element.
6. Click 'Add' to save the catalog item
7. From the 'Service Catalogs' accordion, order the new service. When the dialog appears, select a suitable machine credential, and a different hostname or IP address to the one that was specified when the service template was created.
8. Wait for the service to run successfully.
9. Retire the service.  

Actual results:
The error "fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "sudo: effective uid is not 0, is sudo installed setuid root?
", "module_stdout": "", "msg": "MODULE FAILURE"}"  The retirement playbook was run on localhost.

Expected results:
The retirement playbook should run on the same host or IP address that was specified in the service dialog when the service was ordered, and this overrides the default value defined when the service is created.

Additional info: