{"id":1571,"date":"2016-09-20T12:15:27","date_gmt":"2016-09-20T16:15:27","guid":{"rendered":"http:\/\/blog.domb.net\/?p=1571"},"modified":"2017-05-18T11:45:28","modified_gmt":"2017-05-18T15:45:28","slug":"register-hosts-to-satellite6-via-cloudforms-and-ansible-tower-part-1","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=1571","title":{"rendered":"Register hosts to Satellite6 via CloudForms and Ansible Tower part 1"},"content":{"rendered":"<p>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?<\/p>\n<p>Let\u2019s say we have the following use case:<\/p>\n<p>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. <\/p>\n<p>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.<\/p>\n<p><strong>Part 1<\/strong> 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.<br \/>\n<strong>Part 2<\/strong> 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.<br \/>\n<strong>Part 3 <\/strong>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.<br \/>\n<strong>Part 4<\/strong> Will walk you through the customization of the service dialog to make it dynamic and grab information via api from Red Hat Satellite 6.<\/p>\n<p><strong>Step 1<\/strong> Login to Ansible Tower with an admin user<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1532\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/towerlogin.png\" alt=\"towerlogin\" width=\"556\" height=\"357\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/towerlogin.png 556w, https:\/\/blog.domb.net\/wp-content\/uploads\/towerlogin-300x193.png 300w\" sizes=\"auto, (max-width: 556px) 100vw, 556px\" \/><\/p>\n<p><strong>Step 2 <\/strong> Click on the project tab on the top left<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1573\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/project.png\" alt=\"project\" width=\"110\" height=\"58\" \/><br \/>\n<strong>Step 3<\/strong> Then click +ADD<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1541\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/add.png\" alt=\"add\" width=\"76\" height=\"40\" \/><\/p>\n<p><strong>Step 4<\/strong> Fill in the following information<br \/>\n<em>NAME:<\/em> Can be arbitrary<br \/>\n<em>DESCRIPTION: <\/em>I like to see the giturl of the project there so https:\/\/github.com\/ldomb\/ansible_tower_roles<br \/>\n<em>SCM TYPE:<\/em>git<br \/>\n<em>SCM URL:<\/em>https:\/\/github.com\/ldomb\/ansible_tower_roles<br \/>\n<em>ORGANIZATION: <\/em>In my case default<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1577\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/project1.png\" alt=\"project1\" width=\"1885\" height=\"638\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/project1.png 1885w, https:\/\/blog.domb.net\/wp-content\/uploads\/project1-300x102.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/project1-768x260.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/project1-1024x347.png 1024w\" sizes=\"auto, (max-width: 1885px) 100vw, 1885px\" \/><br \/>\n<strong>Step 5<\/strong> Once done hit save<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1552\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/save.png\" alt=\"save\" width=\"88\" height=\"48\" \/><br \/>\nand go back to the project tab<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1573\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/project.png\" alt=\"project\" width=\"110\" height=\"58\" \/><br \/>\nwhere you will see the following<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1579\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/projecttower.png\" alt=\"projecttower\" width=\"1901\" height=\"286\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/projecttower.png 1901w, https:\/\/blog.domb.net\/wp-content\/uploads\/projecttower-300x45.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/projecttower-768x116.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/projecttower-1024x154.png 1024w\" sizes=\"auto, (max-width: 1901px) 100vw, 1901px\" \/><\/p>\n<p><strong>Step 6<\/strong> Create machine credentials for the hosts you would like to access via ssh. Click on settings<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1536\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/settings.png\" alt=\"settings\" width=\"62\" height=\"59\" \/><br \/>\ncredentials<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1580\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/credentials.png\" alt=\"credentials\" width=\"459\" height=\"145\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/credentials.png 459w, https:\/\/blog.domb.net\/wp-content\/uploads\/credentials-300x95.png 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><br \/>\n+ADD<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1541\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/add.png\" alt=\"add\" width=\"76\" height=\"40\" \/><\/p>\n<p>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:<br \/>\n<a href=\"http:\/\/docs.ansible.com\/ansible\/playbooks_vault.html\">http:\/\/docs.ansible.com\/ansible\/playbooks_vault.html<\/a><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1650\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Selection_020.png\" alt=\"selection_020\" width=\"1826\" height=\"612\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Selection_020.png 1826w, https:\/\/blog.domb.net\/wp-content\/uploads\/Selection_020-300x101.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Selection_020-768x257.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Selection_020-1024x343.png 1024w\" sizes=\"auto, (max-width: 1826px) 100vw, 1826px\" \/><br \/>\nclick +ADD<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1541\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/add.png\" alt=\"add\" width=\"76\" height=\"40\" \/><\/p>\n<p><strong>Step 7<\/strong> 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&#8217;t need a vault password here). As a type choose CloudForms<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1582\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/cfmetower.png\" alt=\"cfmetower\" width=\"1864\" height=\"531\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/cfmetower.png 1864w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmetower-300x85.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmetower-768x219.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmetower-1024x292.png 1024w\" sizes=\"auto, (max-width: 1864px) 100vw, 1864px\" \/><br \/>\nand hit +ADD<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1541\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/add.png\" alt=\"add\" width=\"76\" height=\"40\" \/><br \/>\n<strong>Step 8<\/strong> 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<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1535\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/inventoryscripts.png\" alt=\"inventoryscripts\" width=\"448\" height=\"140\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/inventoryscripts.png 448w, https:\/\/blog.domb.net\/wp-content\/uploads\/inventoryscripts-300x94.png 300w\" sizes=\"auto, (max-width: 448px) 100vw, 448px\" \/><br \/>\nand click the +ADD button.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1541\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/add.png\" alt=\"add\" width=\"76\" height=\"40\" \/><br \/>\nFill in the following values<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1584\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/cfmeinventory.png\" alt=\"cfmeinventory\" width=\"1864\" height=\"501\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/cfmeinventory.png 1864w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmeinventory-300x81.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmeinventory-768x206.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmeinventory-1024x275.png 1024w\" sizes=\"auto, (max-width: 1864px) 100vw, 1864px\" \/><br \/>\nand hit save. You will get redirected to the groups page. Here is where you could add group variables for the CloudForms inventory. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1552\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/save.png\" alt=\"save\" width=\"88\" height=\"48\" \/><br \/>\nClick the ADD Group button and<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1585\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/addgroup.png\" alt=\"addgroup\" width=\"130\" height=\"41\" \/><br \/>\nfill in the following values<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1586\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/cfmegroup.png\" alt=\"cfmegroup\" width=\"1869\" height=\"738\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/cfmegroup.png 1869w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmegroup-300x118.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmegroup-768x303.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/cfmegroup-1024x404.png 1024w\" sizes=\"auto, (max-width: 1869px) 100vw, 1869px\" \/><br \/>\nand hit save<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1552\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/save.png\" alt=\"save\" width=\"88\" height=\"48\" \/><\/p>\n<p><strong>Step 9 <\/strong>Now Sync the inventory on the bottom left corner of the page<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1561\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/sync.png\" alt=\"sync\" width=\"49\" height=\"63\" \/><br \/>\nYou 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.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1587\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/syncsuccessfull.png\" alt=\"syncsuccessfull\" width=\"1906\" height=\"678\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/syncsuccessfull.png 1906w, https:\/\/blog.domb.net\/wp-content\/uploads\/syncsuccessfull-300x107.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/syncsuccessfull-768x273.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/syncsuccessfull-1024x364.png 1024w\" sizes=\"auto, (max-width: 1906px) 100vw, 1906px\" \/><\/p>\n<p><strong>Step 10<\/strong> We are finally ready to create the job in Ansible Tower. Click on the Job Template tab<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1588\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/jobtemplate.png\" alt=\"jobtemplate\" width=\"154\" height=\"61\" \/><br \/>\nclick +ADD<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1541\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/add.png\" alt=\"add\" width=\"76\" height=\"40\" \/><br \/>\nand enter the following values for the job template<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1589\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/jobtemplatesat6.png\" alt=\"jobtemplatesat6\" width=\"1879\" height=\"541\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/jobtemplatesat6.png 1879w, https:\/\/blog.domb.net\/wp-content\/uploads\/jobtemplatesat6-300x86.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/jobtemplatesat6-768x221.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/jobtemplatesat6-1024x295.png 1024w\" sizes=\"auto, (max-width: 1879px) 100vw, 1879px\" \/><\/p>\n<p>Step 11. Add the following values to the EXTRA VARIABLE field<br \/>\n<em>sat6_ip: <\/em> $HOST_IP_ADDR<br \/>\n<em>sat6_fqdn: <\/em> $HOST_FQDN<br \/>\n<em>admin_user:<\/em> admin<br \/>\n<em>org:<\/em> redhat<br \/>\n<em>loc:<\/em> nyc<br \/>\n<em>hostgroup:<\/em> false<br \/>\n<em>activationkey:<\/em> ak-Reg_To_Library_soe_no_puppet<\/p>\n<p>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: \u201c{{ vault_admin_pass}}\u201d.<br \/>\nYou also find instructions on how to do this here:<br \/>\n<a href=\"https:\/\/galaxy.ansible.com\/ldomb\/sat6register\/\">https:\/\/galaxy.ansible.com\/ldomb\/sat6register\/<\/a><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Selection_022.png\" alt=\"selection_022\" width=\"544\" height=\"241\" class=\"alignnone size-full wp-image-1655\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Selection_022.png 544w, https:\/\/blog.domb.net\/wp-content\/uploads\/Selection_022-300x133.png 300w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/p>\n<p>Make sure that the box Prompt on launch is <strong>checked<\/strong>. This is very important as if you don\u2019t do this right you will NOT be able to override any extra_vars from CloudForms when executing the job template.<br \/>\n. We are now done with the Ansible Tower setup. Let&#8217;s go to part 2 which will explain howto setup CloudForms to execute this Job Template.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019s say we have the&#8230;<\/p>\n","protected":false},"author":2,"featured_media":2048,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[64,37,6],"tags":[71,29,68],"class_list":["post-1571","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible","category-cloudforms","category-puppet","tag-ansible-tower","tag-cloudforms","tag-satellite6"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1571"}],"version-history":[{"count":46,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1571\/revisions"}],"predecessor-version":[{"id":1788,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1571\/revisions\/1788"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/2048"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}