Register hosts to Satellite6 via CloudForms and Ansible Tower part 1

CloudForms is the single pane of glass for virtual machines, cloud instances, and baremetal servers provisioned via Satellite 6. Since we added support for Ansible Tower we can do a lot of magic as we can now call Ansible Tower via CloudForms. What does that mean for operations and orchestration?

Let’s say we have the following use case:

We have a host or multiple hosts which need to be registered to Red Hat Satellite 6 and update to the latest errata. We also want to be able to choose if puppet should be used as a configuration management tool or if the host will be managed by Ansible Tower.

CloudForms gives you endless possibilities on how you could achieve this registration. The blog series will walk you through the steps on how to build the above use case through the out of the box integration with Ansible Tower by Red Hat and Red Hat Satellite 6.

Part 1 Will walk you through how to enable the inventory synchronization between CloudForms and Ansible Tower and how to create the sat6register job which will be executed from CloudForms.Part 2 Will walk you through how to auto generate a service dialog in CloudForms from an Ansible Tower Job and expose it as a self service catalog item which can be ordered via self service portal.Part 3 Will walk you through the creation of a custom button sat6register under the VM section which enable you to register a host from the administration ui.Part 4 Will walk you through the customization of the service dialog to make it dynamic and grab information via api from Red Hat Satellite 6.

Step 1 Login to Ansible Tower with an admin user

Step 2 Click on the project tab on the top leftStep 3 Then click +ADD

Step 4 Fill in the following informationNAME: Can be arbitraryDESCRIPTION: I like to see the giturl of the project there so https://github.com/ldomb/ansible_tower_rolesSCM TYPE:gitSCM URL:https://github.com/ldomb/ansible_tower_rolesORGANIZATION: In my case defaultStep 5 Once done hit save
and go back to the project tab
where you will see the following

Step 6 Create machine credentials for the hosts you would like to access via ssh. Click on settings
credentials
+ADD

Fill in the information for your host. In my case I did use username password. In your case it could be an ssh-key. The vault password is used to decrypt the admin_pass password for the Red Hat Satellite 6 connection. You can learn how to set the initial vault password it here:http://docs.ansible.com/ansible/playbooks_vault.html
click +ADD

Step 7 Create the credential to connect to your Red Hat CloudForms appliance. We will need those when we setup the inventory sync between Ansible Tower and Red Hat CloudForms. Repeat Step 6 (You won’t need a vault password here). As a type choose CloudForms
and hit +ADDStep 8 Now we are ready to go and create an inventory for the hosts which are in CloudForms. We need this as ansible is going to ask us about the inventory if we create the job template. Click on the inventory tab
and click the +ADD button.
Fill in the following values
and hit save. You will get redirected to the groups page. Here is where you could add group variables for the CloudForms inventory.

Click the ADD Group button and
fill in the following values
and hit save

Step 9 Now Sync the inventory on the bottom left corner of the page
You will get redirected to the following page. Once the sync is finished you should see a screen similar to this if you have hosts within CloudForms.

Step 10 We are finally ready to create the job in Ansible Tower. Click on the Job Template tab
click +ADD
and enter the following values for the job template

Make sure you create a password in the /roles/sat6register/group_vars/all/vault file as it will be looked up by /roles/sat6register/group_vars/all/vars file containing admin_pass: “{{ vault_admin_pass}}”.
You also find instructions on how to do this here:https://galaxy.ansible.com/ldomb/sat6register/

Make sure that the box Prompt on launch is checked. This is very important as if you don’t do this right you will NOT be able to override any extra_vars from CloudForms when executing the job template.
. We are now done with the Ansible Tower setup. Let’s go to part 2 which will explain howto setup CloudForms to execute this Job Template.