Bug 1753338 - Generic object custom button configured to execute playbook does not execute playbook
Summary: Generic object custom button configured to execute playbook does not execute ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: UI - OPS
Version: 5.11.0
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: GA
: 5.12.0
Assignee: Harpreet Kataria
QA Contact: Tasos Papaioannou
Red Hat CloudForms Documentation
URL:
Whiteboard:
Depends On:
Blocks: 1784190
TreeView+ depends on / blocked
 
Reported: 2019-09-18 15:53 UTC by John Dupuy
Modified: 2020-10-26 16:13 UTC (History)
14 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1784190 (view as bug list)
Environment:
Last Closed: 2020-10-26 16:13:29 UTC
Category: Bug
Cloudforms Team: Ansible
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description John Dupuy 2019-09-18 15:53:17 UTC
Description of problem:
The details of this BZ are confusing but I will do my best to explain all the reproduction steps here. Essentially, if you create a custom button under a generic object class of the "Ansible Playbook" type, and point it at a playbook catalog item, create and add a generic object instance to a service under my service, then click the button to execute the playbook, it doesn't do anything. If the button is not associated with the generic object class, then it will execute.  

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

How reproducible:
100%

Steps to Reproduce:
1. Enable embedded ansible role
2. Add a repo with some playbooks (e.g. https://github.com/ManageIQ/integration_tests_playbooks.git)
3. Add some Ansible credentials for a VMware provider
4. Create a catalog named "Catalog VMware"
5. Create a catalog item "VMware Catalog Item" under this catalog that executes a playbook, if you're using the above repo you can use e.g. "gather_all_vms_from_vmware.yml"
6. Order the service catalog and ensure that the playbook runs successfully
7. Now create a separate catalog "Test Custom Button"
8. Create a "generic" catalog item under this catalog "test custom button"
9. Order this service and ensure that the service appears under My Services
10. Create a generic object class "Test class"
11. Create a custom button of type "Ansible Playbook" that uses the catalog item "VMware Catalog Item", with "Request" -> "Order_Ansible_Playbook"
12. Create a generic object instance under "Test class"
13. Associate the generic object instance with the service "Test Custom Button"
    This can be done by REST action "add_resource" or by the rails console
14. Navigate to Services > My services > Services > Active Services > Test Custom Button
15. In the generic objects summary table, there should be one instance associated with the service, click this instance
16. Click the generic object quadicon
17. The custom button you created in step 11 should be displayed, click that button. 
18. Hit submit

Actual results:
The playbook is not executed, no trace of the playbook being triggered in the logs at all

Expected results:
The playbook should be executed

Additional info:
If you create a button in "Automation > Automate > Customization > Buttons > Generic Objects" (i.e. not associated with a generic object class, but does the same thing as the button in step 11) then this button also appears on the page in step 17, and clicking this button DOES result in the playbook being executed. 

I am not sure if this is a valid use case, but I would still expect it to work given that it works for the scenario in the sentence above. 

Note: there are several BZs associated with custom buttons that are associated with the generic object classes
bug 1753237, 1753281

It is not clear whether this is an embedded ansible issue or a generic object custom button issue.

Comment 2 John Dupuy 2019-09-18 16:00:25 UTC
Note that for step 11., the custom button must be made under: Automation > Automate > Generic Objects > All Generic Object Classes

Comment 3 dmetzger 2019-09-18 19:44:49 UTC
Can the associated logs be attached for analysis?

Comment 11 drew uhlmann 2019-10-01 14:05:06 UTC
Hey John, has that appliance been updated? I'm not seeing services or custom buttons on it.

Comment 12 John Dupuy 2019-10-01 14:20:01 UTC
Drew, the original appliance was deleted and likely that IP was assigned to a different appliance.

Comment 13 drew uhlmann 2019-10-01 14:21:02 UTC
Ah, then may I please have another reproducer?

Comment 15 drew uhlmann 2019-10-01 20:31:19 UTC
`:attrs=>{"request"=>"Order_Ansible_Playbook"` vs `:attrs=>{:request=>"Order_Ansible_Playbook"`

The nonworking one looks like it's using keys that are strings, not symbols.

Comment 16 drew uhlmann 2019-10-02 13:25:49 UTC
I guess comment 15 is a symptom of the fact that we're storing uri_attributes for custom_buttons like this: 
CustomButton.find(3).uri_attributes
=> {"request"=>"Order_Ansible_Playbook", :service_template_name=>"list VMs playbook", :hosts=>"localhost"}

as both strings and symbols, which certainly can't be great in the UI when hitting, for example, https://github.com/ManageIQ/manageiq-ui-classic/blob/cec300bbea3bb7ab4e46b17400b07bdc4b593804/app/controllers/miq_ae_customization_controller/custom_buttons.rb#L70.

Comment 19 drew uhlmann 2019-10-03 16:40:47 UTC
Hey Harpreet, based on comment 17 and comment 18, could I get you to please take a look at this one?

Comment 22 CFME Bot 2019-12-13 10:01:22 UTC
New commit detected on ManageIQ/manageiq-ui-classic/master:

https://github.com/ManageIQ/manageiq-ui-classic/commit/1048a770cd9a862543f1daec2f76e2a10995fa13
commit 1048a770cd9a862543f1daec2f76e2a10995fa13
Author:     Harpreet Kataria <hkataria>
AuthorDate: Wed Dec 11 16:03:23 2019 -0500
Commit:     Harpreet Kataria <hkataria>
CommitDate: Wed Dec 11 16:03:23 2019 -0500

    Fixed code to pass in `service_template` in ae_attributes hash

    When creating a new GO Playbook custom button, code expects service_template to be included in the ae_attributes hash in order to save the value correctly inside uri_attributes.

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

 app/assets/javascripts/components/generic_object/main-custom-button-form.js | 1 +
 spec/javascripts/components/generic_object_definition/main-custom-button-form_spec.js | 1 +
 2 files changed, 2 insertions(+)

Comment 24 drew uhlmann 2020-01-16 19:38:44 UTC
The method was missing the service template name in the root object, we provided that, it all ran well. 
I believe that Harpreet's original fix addresses a valid issue.


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