This series is highlighting the improvements and new capabilities introduced with CloudForms 4.6 about Ansible Custom Buttons.
The Ansible Playbook used in this example will install a user-specified package on the selected virtual machine.
- CloudForms 4.6
Adding a Repository
The sample playbooks needed for this article can be found in the following GIT repository.
Add the repository by navigating to Automation, Ansible, Repositories and then click on Configuration, Add a new Repository
Fill out the form with the correct a name, description and the correct link. SCM credentials are not needed since this is a public repository.
After clicking on Add the import is running in the background and it can take a few moments to complete.
You can view the status of adding the repository by clicking on your username in the top right corner and then Tasks, All Tasks.
The repository will automatically refresh and sync the playbooks to CloudForms.
You can view the repository by clicking Automation, Ansible, Repositories:
Click the repository you will see the inventory details of the repository.
You can also view the list of playbooks by clicking the Playbooks field.
Finally, you can select a playbook and view its details too by clicking its row in the list.
For Ansible to be able to log into the selected Virtual Machine, the login credentials have to be stored in CloudForms.
Navigate to Automation, Ansible, Credentials and click on Configuration, Add New Credentials.
The example below is using the user root to log into the Virtual Machine. Best practice is to create dedicated accounts CloudForms can login with and use privilege escalation when needed.
Click on Add to save the credentials. Like most actions in CloudForms, this is performed in the background and will take a moment. A pop-up notification will inform you about the success.
Creating a Service
Although this has been explained a number of times in the blog, as a reminder, to be able to create a custom button which executes an Ansible Playbook, we have to create a service catalog item first. This service catalog item will not be presented to end users and will not be visible in the catalog.
First, we need to create a Catalog to store the service in (assuming this is a brave new environment), do this by clicking Services, Catalogs and then Catalogs in the accordion on the left. Create a new Catalog by clicking on the Configuration button and selecting Add New Catalog.
Create a new catalog as follows;
Now select Catalog Items, Samples and create new by clicking Configuration button and selecting Add New Catalog Item.
Select the Catalog Item Type as Ansible Playbook
Fill out the new catalog item as follows for the Provisioning Tab.
Pay special attention to the following fields:
- An extra variable package_name was added
- The machine credentials were set, in this example the previously created credentials were selected
- The dialog was set to Create New and given a name.
This Ansible Playbook has no retirement counterpart and the details in the respective Retirement dialog can be left unchanged.
The added catalog item also creates a new dialog to serve the item.
You can click on the Service Catalog Item to verify the details:
Stay tuned for the next part