Custom Buttons with Ansible

Add a button to a Virtual Machine

CloudForms can easily be extended by adding additional menus and buttons. This allows seamless integration of customization and making them available to end users.

Add a Button Group

To add new button to the UI, we first need to create a Button Group. A Button Group is basically a new menu entry in the UI. Buttons and Button Groups can be assigned to several objects in CloudForms.

  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 VM and Instance

    navigate to vm and instance

  4. Click on Configuration -> Add a new Button Group

  5. Enter the following data into the form:

    The name of the Button Group, or menu, as shown in the UI:

    Text: Tools

    A description text which will be shown when hovering the mouse over the Button Group:

    Hover Text: Additional tasks

    An icon for the Button Group:

    Icon: search for the wrench symbol in Font Awesome

    pick Wrench symbol

    tools button group

  6. Click Add to create the button group

In the next section we will add a button to the group.

Add a new Button to the Button Group

The previous step created a Button Group, or menu. Now we want add Buttons to the Group:

  1. Navigate to Automation -> Automate -> Customization

    navigate to Customization

    :heavy_check_mark: NOTE You should already be in this menu if you followed the previous steps

  2. Click on the “Tools” Button Group you created in the previous lab

    navigate to tools button group

  3. Click on Configuration -> Add a new Button

    add a new button to group

  4. Make the following adjustments:

    There are different Button types to extend the CloudForms UI:

    Button Type: Ansible Playbook

    Which action should be performed, when a user submits the request. In this example we call the previously created Service Catalog Item, which runs an Ansible Playbook.

    Playbook Catalog Item: Install Package - this is the Service Catalog Item you created in the previous part of the lab

    On which target system should the Ansible Playbook run? For this lab, we want it to be executed on the selected machine:

    Inventory: Target Machine

    The name of the Button which will be shown in the UI and should be short and descriptive:

    Text: Install Package

    A more descriptive text which will be shown if the user hovers the mouse over the Button.

    Hover Text: Install additional package

    An icon to make the Button easy to find:

    Icon: Select the Software Package Icon at the “Font Fabulous” tab and click Apply

    select software package icon

    create Ansible Button

  5. Click Add to save the Button

This adds a new Button to the Button Group “Tools”.

Test the Ansible Button Customization

We want to test the resulting customization and see how it works from a user point of view.

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

    navigate to virtual machines

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

    VM cfme008 is turned on

  3. On the details page of “cfme008” note the new menu “Tools”. Click to see the new button “Install Package”

    VM with additional tools menu

  4. Click on Tools -> Install Package

    Ansible button dialog

  5. We can accept the values and click on Submit

  6. Navigate to Services -> My Services

    navigate to Services, My Services

    :heavy_check_mark: NOTE You might have to click on Active Services to see the updated overview of all your 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

:heavy_check_mark: NOTE Ansible is idempotent - this means you can run the same Playbook many times and Ansible detects if the desired state was already reached. In this lab, no changes are necessary, because the package httpd is already installed.

This concludes this part of the Ansible lab.