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
towerlogin

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

Step 4 Fill in the following information
NAME: Can be arbitrary
DESCRIPTION: I like to see the giturl of the project there so https://github.com/ldomb/ansible_tower_roles
SCM TYPE:git
SCM URL:https://github.com/ldomb/ansible_tower_roles
ORGANIZATION: In my case default
project1
Step 5 Once done hit save
save
and go back to the project tab
project
where you will see the following
projecttower

Step 6 Create machine credentials for the hosts you would like to access via ssh. Click on settings
settings
credentials
credentials
+ADD
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
selection_020
click +ADD
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
cfmetower
and hit +ADD
add
Step 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
inventoryscripts
and click the +ADD button.
add
Fill in the following values
cfmeinventory
and hit save. You will get redirected to the groups page. Here is where you could add group variables for the CloudForms inventory.

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

Step 9 Now Sync the inventory on the bottom left corner of the page
sync
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.
syncsuccessfull

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

Step 11. Add the following values to the EXTRA VARIABLE field
sat6_ip: $HOST_IP_ADDR
sat6_fqdn: $HOST_FQDN
admin_user: admin
org: redhat
loc: nyc
hostgroup: false
activationkey: ak-Reg_To_Library_soe_no_puppet

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/
selection_022

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


Hit Counter provided by laptop reviews