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.

Navigate to Automation -> Automate -> Customization

navigate to Customization

Click on Buttons in the accordion on the left

navigate to buttons

Click on VM and Instance

navigate to vm and instance

Click on Configuration -> Add a new Button Group

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

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:

Navigate to Automation -> Automate -> Customization

navigate to Customization

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

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

navigate to tools button group

Click on Configuration -> Add a new Button

add a new button to group

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

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.

Navigate to Compute -> Infrastructure -> Virtual Machines

navigate to virtual machines

Click on the “cfme008” tile if not already selected

VM cfme008 is turned on

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

VM with additional tools menu

Click on Tools -> Install Package

Ansible button dialog

We can accept the values and click on Submit

Navigate to Services -> My Services

navigate to Services, My Services

You might have to click on Active Services to see the updated overview of all your services.

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.

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

details of Ansible Playbook

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

Ansible Playbook output

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.