{"id":2183,"date":"2017-10-17T12:36:06","date_gmt":"2017-10-17T16:36:06","guid":{"rendered":"http:\/\/blog.domb.net\/?p=2183"},"modified":"2018-04-25T10:00:36","modified_gmt":"2018-04-25T14:00:36","slug":"servicenow-snow-inventory-for-ansible-tower-3-2-1","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=2183","title":{"rendered":"ServiceNow (snow) inventory for Ansible Tower 3.2.1"},"content":{"rendered":"<p>If you are a ServiceNow user you can now go to\u00a0https:\/\/github.com\/ServiceNowITOM\/ansible-sn-inventory use the dynamic inventory available to sync CI items from Service Now to ansible tower. This tutorial will show what you need to do to make this happen on ansible tower 3.2.1. A big thanks to Reuben Stump, Alex Mittell for writing this integration.<\/p>\n<p class=\"p1\"><span class=\"s1\">Step 1. Install the python-configparser from epel\u00a0<\/span><\/p>\n<pre class=\"lang:default decode:true\">[root@towerldo ~]# wget http:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/Packages\/p\/python-configparser-3.5.0b2-1.el7.noarch.rpm\r\n[root@towerldo ~]# rpm -ivh python-configparser-3.5.0b2-1.el7.noarch.rpm \r\n<\/pre>\n<p>Step 2. create the file now.ini and place it in \/etc\/ansible\/now.ini<\/p>\n<p>You can find the file here:\u00a0\u00a0<a href=\"https:\/\/raw.githubusercontent.com\/ServiceNowITOM\/ansible-sn-inventory\/master\/now.ini\" target=\"_blank\" rel=\"noopener\">now.ini<\/a><\/p>\n<p>Modify the instance, user and password.<\/p>\n<pre class=\"lang:default decode:true\">[root@towerldo ~]# cat &lt;&lt; EOF &gt; \/etc\/ansible\/now.ini\r\n# Ansible ServiceNow external inventory script settings\r\n\r\n[defaults]\r\n\r\n# Specify the number of seconds to use the inventory cache before it is\r\n# considered stale.  If not defined, defaults to 0 seconds.\r\n#cache_max_age = 3600\r\n\r\n# Specify the directory used for storing the inventory cache.  If not defined,\r\n# caching will be disabled.\r\n#cache_dir = .cache\/ansible\r\n\r\n[auth]\r\n\r\n# The ServiceNow instance URI. The URI should be the fully-qualified domain name, e.g. 'your-instance.servicenow.com'.\r\n# This setting may also be defined via the SN_INSTANCE environment variable.\r\n\r\ninstance = myinstance.service-now.com\r\n\r\n# The ServiceNow instance user name. The user acount should have enough rights to read the cmdb_ci_server table.\r\n# This setting may also be defined with the SN_USERNAME environment variable.\r\n\r\nuser = iruser\r\n\r\n# The ServiceNow instance user password.\r\n# This setting may also be defined with the SN_PASSWORD environment variable.\r\n\r\npassword = icanhasaccess\r\n\r\n[config]\r\n\r\n# Comma seperated string providing additional table columns to use as groups. Groups can overlap with fields.\r\n\r\n#groups = 'company, os'\r\n\r\n# Comma seperated string providing additional table columns to add as host vars to each inventory host.\r\n\r\n#fields = 'company, os, os_version'\r\nEOF<\/pre>\n<p>Step 2. Login to Ansible Tower and add a custom inventory under Settings -&gt; Inventory Scripts -&gt; ADD. For the custom script go get the\u00a0\u00a0<a href=\"https:\/\/raw.githubusercontent.com\/ServiceNowITOM\/ansible-sn-inventory\/master\/now.py\" target=\"_blank\" rel=\"noopener\">now.py<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2198\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.11.19-PM.png\" alt=\"\" width=\"3374\" height=\"887\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.11.19-PM.png 3374w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.11.19-PM-300x79.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.11.19-PM-768x202.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.11.19-PM-1024x269.png 1024w\" sizes=\"auto, (max-width: 3374px) 100vw, 3374px\" \/><\/p>\n<p>Step 3. Go create an inventory under Inventory -&gt; ADD -&gt; Inventory<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2185\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.16-PM.png\" alt=\"\" width=\"1478\" height=\"706\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.16-PM.png 1478w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.16-PM-300x143.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.16-PM-768x367.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.16-PM-1024x489.png 1024w\" sizes=\"auto, (max-width: 1478px) 100vw, 1478px\" \/><\/p>\n<p>Step 4. Then click on Sources and add<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2186\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.37-PM.png\" alt=\"\" width=\"1481\" height=\"893\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.37-PM.png 1481w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.37-PM-300x181.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.37-PM-768x463.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.28.37-PM-1024x617.png 1024w\" sizes=\"auto, (max-width: 1481px) 100vw, 1481px\" \/><\/p>\n<p>Step 5. Before you can go ahead and sync you will need to set the env var NOW_INI. You can do this in Settings -&gt; Configure Tower -&gt; Jobs -&gt; Extra Environment Variables<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2199\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM.png\" alt=\"\" width=\"1132\" height=\"1132\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM.png 1132w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM-150x150.png 150w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM-300x300.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM-768x768.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM-1024x1024.png 1024w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM-250x250.png 250w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-27-at-12.13.53-PM-174x174.png 174w\" sizes=\"auto, (max-width: 1132px) 100vw, 1132px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Step 6. You are now ready to sync. Click on the sync button<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2187\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.13-PM.png\" alt=\"\" width=\"1450\" height=\"391\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.13-PM.png 1450w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.13-PM-300x81.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.13-PM-768x207.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.13-PM-1024x276.png 1024w\" sizes=\"auto, (max-width: 1450px) 100vw, 1450px\" \/><\/p>\n<p>Step 7. If your sync was successful you should see the following under jobs<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2188\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.29-PM.png\" alt=\"\" width=\"1902\" height=\"1054\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.29-PM.png 1902w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.29-PM-300x166.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.29-PM-768x426.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2017-10-17-at-12.30.29-PM-1024x567.png 1024w\" sizes=\"auto, (max-width: 1902px) 100vw, 1902px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are a ServiceNow user you can now go to\u00a0https:\/\/github.com\/ServiceNowITOM\/ansible-sn-inventory use the dynamic inventory available to sync CI items from Service Now to ansible tower. This tutorial will show what you need to do to make this happen on ansible tower 3.2.1. A big thanks to Reuben Stump, Alex Mittell for writing this integration&#8230;.<\/p>\n","protected":false},"author":2,"featured_media":2189,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[64],"tags":[71,131,128,130,132],"class_list":["post-2183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible","tag-ansible-tower","tag-ansibletower","tag-inventory","tag-service-now","tag-snow"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2183","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=2183"}],"version-history":[{"count":9,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2183\/revisions"}],"predecessor-version":[{"id":2424,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2183\/revisions\/2424"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/2189"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}