{"id":1522,"date":"2017-10-15T23:47:30","date_gmt":"2017-10-16T03:47:30","guid":{"rendered":"http:\/\/blog.domb.net\/?p=1522"},"modified":"2017-10-15T17:24:51","modified_gmt":"2017-10-15T21:24:51","slug":"rhv-4-0-rhev-4-0-dynamic-inventory-for-ansible-tower","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=1522","title":{"rendered":"RHV 4.1 \/ RHEV 4.1 Dynamic Inventory For Ansible Tower"},"content":{"rendered":"<p>Out of the box Ansible Tower 3.1.2 does not come with the Red Hat Virtualization 4.0 provider. You will find the instructions here to get it working:<\/p>\n<p>Step 1: SSH into the ansible tower<\/p>\n<p><code>[dobby@dobby ~]$ ssh root@tower.local.domb.com <\/code><\/p>\n<p>Step 2: Install ovirt-engine-sdk-python<br \/>\n<code>[root@towerldo ~]# yum install ovirt-engine-sdk-python<\/code><\/p>\n<p>Step 3: cd into \/opt\/rh and get the ovirt.ini file<br \/>\n<code>[root@towerldo ~]# cd \/opt\/rh<br \/>\n[root@towerldo ~]# wget https:\/\/raw.githubusercontent.com\/ldomb\/rhv4-for-tower\/master\/ovirt.ini <\/code><\/p>\n<p>Step 4: Edit the values in \/opt\/rh\/ovirt.ini with your correct RHV4 url (the path after your FQDN is &#8220;<strong>ovirt-engine\/api<\/strong>&#8221; and password for the admin user<br \/>\n<code>[root@towerldo ~]# cat \/opt\/rh\/ovirt.ini<br \/>\n# Ansible RHV ini file<br \/>\n#<br \/>\n# Ansible is free software: you can redistribute it and\/or modify<br \/>\n# it under the terms of the GNU General Public License as published by<br \/>\n# the Free Software Foundation, either version 3 of the License, or<br \/>\n# (at your option) any later version.<br \/>\n#<br \/>\n# Ansible is distributed in the hope that it will be useful,<br \/>\n# but WITHOUT ANY WARRANTY; without even the implied warranty of<br \/>\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br \/>\n# GNU General Public License for more details.<br \/>\n#<br \/>\n# You should have received a copy of the GNU General Public License<br \/>\n# along with Ansible.  If not, see .<\/code><\/p>\n<p># Author: Laurent Domb based on Josha Inglis ovirt.ini for ovirt 3.6 and the gce.ini by Eric Johnson<\/p>\n<p>[ovirt]<br \/>\n# ovirt Service Account configuration information can be stored in the<br \/>\n# libcloud &#8216;secrets.py&#8217; file. Ideally, the &#8216;secrets.py&#8217; file will already<br \/>\n# exist in your PYTHONPATH and be picked up automatically with an import<br \/>\n# statement in the inventory script. However, you can specify an absolute<br \/>\n# path to the secrets.py file with &#8216;libcloud_secrets&#8217; parameter.<br \/>\novirt_api_secrets =<\/p>\n<p># If you are not going to use a &#8216;secrets.py&#8217; file, you can set the necessary<br \/>\n# authorization parameters here.<br \/>\novirt_url = https:\/\/rhv.local.domb.com\/ovirt-engine\/api<br \/>\novirt_username = admin@internal<br \/>\novirt_password = iloveopensource<\/p>\n<p>Step 5. Now login into ansible tower as privileged user who is allowed to add an inventory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"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>Step 6. Got to Settings<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1536\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/settings.png\" alt=\"settings\" width=\"62\" height=\"59\" \/><br \/>\nInventory Scripts<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1538\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/inventoryscripts-1.png\" alt=\"inventoryscripts\" width=\"465\" height=\"163\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/inventoryscripts-1.png 465w, https:\/\/blog.domb.net\/wp-content\/uploads\/inventoryscripts-1-300x105.png 300w\" sizes=\"auto, (max-width: 465px) 100vw, 465px\" \/><\/p>\n<p>And click on &#8220;Create a new custom inventory&#8221;<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1541\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/add.png\" alt=\"add\" width=\"76\" height=\"40\" \/><\/p>\n<p>Step 7. Add a name<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1545\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/name.png\" alt=\"name\" width=\"624\" height=\"266\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/name.png 624w, https:\/\/blog.domb.net\/wp-content\/uploads\/name-300x128.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>Step 8. For the Custom Script get the https:\/\/raw.githubusercontent.com\/ldomb\/rhv4-for-tower\/master\/ovirt.py and paste the content into the field<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1550\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/custom.png\" alt=\"custom\" width=\"668\" height=\"380\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/custom.png 668w, https:\/\/blog.domb.net\/wp-content\/uploads\/custom-300x171.png 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/p>\n<p>and click 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>Step 9. click on inventories<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1554\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/inventories.png\" alt=\"inventories\" width=\"371\" height=\"67\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/inventories.png 371w, https:\/\/blog.domb.net\/wp-content\/uploads\/inventories-300x54.png 300w\" sizes=\"auto, (max-width: 371px) 100vw, 371px\" \/><br \/>\nand 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>Step 10. In new inventory enter a name for you new RHV4 inventory<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1556\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/newinventory.png\" alt=\"newinventory\" width=\"1140\" height=\"455\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/newinventory.png 1140w, https:\/\/blog.domb.net\/wp-content\/uploads\/newinventory-300x120.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/newinventory-768x307.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/newinventory-1024x409.png 1024w\" sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" \/><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\" \/><br \/>\nYou will get redirected to the groups page where you create new group (+ ADD GROUP).<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1558\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/group.png\" alt=\"group\" width=\"940\" height=\"74\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/group.png 940w, https:\/\/blog.domb.net\/wp-content\/uploads\/group-300x24.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/group-768x60.png 768w\" sizes=\"auto, (max-width: 940px) 100vw, 940px\" \/><\/p>\n<p>Step 11. For inventory choose custom script and add the script we added in step 7 under Custom Inventory Script<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1560\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/group2.png\" alt=\"group2\" width=\"1467\" height=\"355\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/group2.png 1467w, https:\/\/blog.domb.net\/wp-content\/uploads\/group2-300x73.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/group2-768x186.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/group2-1024x248.png 1024w\" sizes=\"auto, (max-width: 1467px) 100vw, 1467px\" \/><\/p>\n<p>Step 12. Once saved go back to the inventories tab and click on you new inventory<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>Step 13. You can new sync your new inventory by pressing the sync button<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\" \/><\/p>\n<p>Step 14. If everything goes well you should see something like<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1562\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/outputrhev.png\" alt=\"outputrhev\" width=\"1833\" height=\"696\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/outputrhev.png 1833w, https:\/\/blog.domb.net\/wp-content\/uploads\/outputrhev-300x114.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/outputrhev-768x292.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/outputrhev-1024x389.png 1024w\" sizes=\"auto, (max-width: 1833px) 100vw, 1833px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Out of the box Ansible Tower 3.1.2 does not come with the Red Hat Virtualization 4.0 provider. You will find the instructions here to get it working: Step 1: SSH into the ansible tower [dobby@dobby ~]$ ssh root@tower.local.domb.com Step 2: Install ovirt-engine-sdk-python [root@towerldo ~]# yum install ovirt-engine-sdk-python Step 3: cd into \/opt\/rh and get the&#8230;<\/p>\n","protected":false},"author":2,"featured_media":2027,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[64],"tags":[71,72,73],"class_list":["post-1522","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible","tag-ansible-tower","tag-rhv","tag-rhv-4"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1522","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=1522"}],"version-history":[{"count":35,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1522\/revisions"}],"predecessor-version":[{"id":2176,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/1522\/revisions\/2176"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/2027"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}