Delivering "Push Button" Automation Integrating CloudForms and Ansible Tower

Today I will be taking you on a quick expedition on how you can integrate two modern Red Hat products to help automate your business. In this example, the button writes to the /etc/motd file of a specific VM using a very simple role from Ansible Galaxy.

Ansible is one of the most popular open source automation and configuration projects. With Ansible Tower, you have an enterprise solution for IT automation. Ansible Tower is a web-based interface for managing Ansible. It's used for managing quick deployments and monitoring configurations. It also provides enterprises more control in the realm of configuration management. The flexibility of Ansible has made it the go-to automation tool not only for us, but for our customers as well.

On the other hand, CloudForms is a hybrid cloud management platform which is based on the ManageIQ open source project. CloudForms unifies management across clouds with insight & discovery and provides full operational control. IT infrastructure operators are always searching for a single tool to help manage their environments. CloudForms is that one solution that provides extensive capabilities across configuration management, orchestration, governance and automation. CloudForms aims to integrate into your existing infrastructure, rather than trying to replace existing functional tooling and processes.

Ansible playbook used:

---
- name: MOTD
  hosts: all
  pre_tasks:
    - name: install selinux for role
      yum: pkg=libselinux-python state=latest
  vars:
    motd_ascii_art: "ˁ˚ᴥ˚ˀ   ARCTIQ   ˁ˚ᴥ˚ˀ"
  roles:
    - jtyr.motd
    

Ansible Tower Job Project and Template Configuration:

Login to Ansible Tower and then click on Projects .
Click on the " +" icon on the top right hand corner.
Add your name, SCM Type and URL, Organization. It's also a good idea to check the "Update on Launch" setting.

Next, click on Job Templates and add a new job template.

I named mine message_of_the_day, choose your inventory, choose your project, the playbook in your repository and choose your machine credentials. Click save:

Initial CloudForms Configuration:

To connect Ansible Tower to CloudForms, credentials are needed for the Tower API. This is consistent for all CloudForms providers.

Navigate to Configuration -> Configuration Management -> Providers accordian -> All Configuration Manager Providers -> Configuration -> Add a new Provider. Add your name, type, URL and Credentials:

Job Template Configuration in CloudForms:

Now login to CloudForms.

Click on Configuration -> Configuration Management -> Ansible Tower Job Templates and then click on your Ansible Configuration Manager.

Here the motd job template should be visible, otherwise refresh:

Next, Click on the message_of_the_day template. Then click on Configuration -> Create Service Dialog from this Job Template.

Name your service dialog and hit save. I named mine "Message of the Day".

Create Button and connect it to the Job Template in Ansible Tower:

In CloudForms click on Automate -> Customization and then Buttons accordion. Choose VM and Instance -> Configuration (at the top) -> Add a new Button Group. Add your Button Group Text, Hover Text and Image. Click add.

Next, create a VM button and add it to the group created above.

Navigate to the button group you just created. Click on configuration and then Add a new Button.

Add your Button text, Hover text and button. For dialog choose the dialog you created before. For System/Process select Request and for Request enter Ansible_Tower_Job.

For Attribute/Value pairs enter: job_template_name with your job template name (from Ansible Tower)

Navigate to your VM by going to Compute -> Infrastructure -> Virtual Machines. Click on your VM. You should see your Button Group at the top of the page. Click on the button group and then click on your button to start the playbook and click Submit.

Navigate to Ansible Tower and click on Jobs. Monitor the job running:

After you see "successful" next to your playbook run, login to your VM to see the updated motd message.

So there you have it, a quick walkthrough covering how easy it is to combine these two platforms. I’ve found that it’s pretty easy to automate tasks and simplify them with CloudForms and Ansible Tower.

If you found this helpful, next there will a similar tutorial with the integration of CloudForms, Ansible, and Satellite 6. If you would like to discuss CloudForms and Ansible in more detail, click the link below and...