Improve Service Dialogs

Improve the Service Dialog

The automatically generated Service Dialog is far from being perfect. It might confuse the user with too many input fields. For example, the user is asked to select the “Machine Credentials”, although they have already been defined in the Service Catalog Item and the user provided input will have no effect. It also asks for the “Host”, but this one is automatically calculated by CloudForms and set to the currently selected Virtual Machine. And finally the field “package_name” could benefit from a more descriptive text to be more user friendly.

In the following steps, we want to make the Service Dialog more user friendly by simplifying it.

Edit the Service Dialog

  1. Navigate to Automation -> Automate -> Customization

    navigate to Customization

  2. Click on Service Dialogs in the accordion on the left

    navigate to Service Dialogs

  3. Click the check box next to “InstallPackage”

  4. Click on Configuration -> Copy the selected Dialog to a new Dialog

    copy install package service dialog

  5. Let’s improve the Service Dialog by applying the following changes:

    Dialog’s name: Install Package from Button

  6. Hide the element “Machine Credentials” by clicking on the little pen icon.

    edit machine credentials
    :heavy_check_mark: NOTE The edit icon only shows if you move the mouse pointer over the “Machine Credentials” text box.

    :warning: WARNING Do not delete the element, only hide it! The element is still needed for some CloudForms internal logic and should not be removed.

  7. Click on Overridable Options and switch the Visible switch to “No”

    visible no for machine credentials

  8. Click Save to close the dialog

  9. Repeat this for the “Hosts” element. Click on the pen icon next to it.

    edit hosts

    :heavy_check_mark: NOTE The edit icon only shows if you move the mouse pointer over the “Hosts” text box.

  10. Click on Options and switch Visible to “No”

    visible no for hosts

    :warning: WARNING Do not delete the element, only hide it! The element is still needed for some CloudForms internal logic and should not be removed.

  11. Click on the little pen icon next to the “package_name” text box

    :heavy_check_mark: NOTE The edit icon only shows if you move the mouse pointer over the “package_name” text box.

  12. Change the label to something more descriptive:

    Label: Enter Package Name

    :warning: WARNING Do not change the field “Name” - it is the name of the variable used internally by CLoudForms and the Ansible Playbook. if you change the name of this field, the Playbook will not pickup the new variable and hence ignore the user input.

  13. Also let’s give more information to the user by improving the “Help” text:

    Help: Enter the name of the RPM package to be installed on the system

    package_name field details

  14. Click Save to apply the changes

    install package Service Dialog

  15. Click Save To save all changes we made in the Service Dialog

This concludes this part of the lab.

Create improved Service Catalog Item

To be able to use the new Service Dialog with our button, we first have to create an additional Service Catalog Item, which points to the Service Dialog.

  1. Navigate to Services -> Catalogs

    navigate to Services Catalogs

  2. Navigate to Catalog Items in the accordion on the left

    navigate to Catalog Items

  3. Click on Configuration -> Add a New Catalog Item

    create new catalog item

  4. Select Ansible Playbook as Catalog Item Type

    select ansible playbook as type

  5. Use the following parameters when defining the Service Catalog Item:

    Name: Install Package from Button

    Description: Install Package via Ansible Playbook

    Display in Catalog: Yes

    Long Description: <empty>

    This is an optional field to provide a more detailed description. If you want, you can be creative here. CloudForms even supports HTML formatting which is often used to embed links to Documentation or additional resources on the selected Service Catalog Item.

    Catalog: My Company/Ansible

    Repository: GitLab

    Playbook: playbooks/InstallPackage.yml

    Machine Credentials: Virtual Machine credentials

    Variables & Default Values: add one new entry with:

    Variable: package_name

    Default Value: httpd

    :heavy_check_mark: NOTE Click the little plus (“+”) icon to save the row.

    Dialog: Use Exiting

    Use “Install Package from Button” as the name of the Dialog, which is the one we created in the step before.

    dialog to create InstallPackage Service Catalog Item

    dialog with InstallPackage Advanced Button

  6. Click Add to save all changes

Update the Button definition

As the last step, we have to change the definition of our button, to point to the just created Service Catalog Item.

  1. Navigate to Automation -> Automate -> Customization

    navigate to Customization

  2. Click on Buttons in the accordion on the left

    navigate to buttons

  3. Click on the “Install Package” Button you created in the previous lab

    navigate to tools button group

  4. Click on Configuration -> Edit this Button

  5. Change the Playbook Catalog item to the new one you just created “Install Package from Button”

    change playbook catalog item

  6. Click Save to store all changes

Test the improved Button

  1. Navigate to Compute -> Infrastructure -> Virtual Machines

    navigate to virtual machines

  2. Click on the “cfme008” tile if not already selected

    VM cfme001 is turned on

  3. On the details page of “cfme008” click on Tools -> Install Package

    VM with additional tools menu

  4. Click on Tools -> Install Package

    Ansible button dialog

    You should see the simplified version of the Dialog. The Package Name has a better description, there is a tool tip if you hover the mouse over the little “i” icon and the redundant fields for “Machine Credentials” and “Hosts” are gone.

  5. Click Submit to execute the Button action

  6. Navigate to Services -> My Services

    navigate to Services, My Services

  7. As a result of your action, a new “My Services” object was created. If you don’t see it yet, wait a minute and click on the reload button.

  8. Click on the “Install Playbook” item to see the details

    details of Ansible Playbook

  9. Click on the Provisioning tab to see output from your Ansible Playbook

    Ansible Playbook output

This concludes this part of the Ansible lab.

:+1: OPTIONAL Feel free to repeat this part of the lab with a different package name. You could use “screen” as an example instead of httpd - or some other package you want to install.