ServiceNow (snow) inventory for Ansible Tower 3.2.1

If you are a ServiceNow user you can now go to https://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.

Step 1. Install the python-configparser from epel 

[root@towerldo ~]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/python-configparser-3.5.0b2-1.el7.noarch.rpm
[root@towerldo ~]# rpm -ivh python-configparser-3.5.0b2-1.el7.noarch.rpm 

Step 2. create the file now.ini and place it in /etc/ansible/now.ini

You can find the file here:  now.ini

Modify the instance, user and password.

[root@towerldo ~]# cat << EOF > /etc/ansible/now.ini
# Ansible ServiceNow external inventory script settings

[defaults]

# Specify the number of seconds to use the inventory cache before it is
# considered stale.  If not defined, defaults to 0 seconds.
#cache_max_age = 3600

# Specify the directory used for storing the inventory cache.  If not defined,
# caching will be disabled.
#cache_dir = .cache/ansible

[auth]

# The ServiceNow instance URI. The URI should be the fully-qualified domain name, e.g. 'your-instance.servicenow.com'.
# This setting may also be defined via the SN_INSTANCE environment variable.

instance = myinstance.service-now.com

# The ServiceNow instance user name. The user acount should have enough rights to read the cmdb_ci_server table.
# This setting may also be defined with the SN_USERNAME environment variable.

user = iruser

# The ServiceNow instance user password.
# This setting may also be defined with the SN_PASSWORD environment variable.

password = icanhasaccess

[config]

# Comma seperated string providing additional table columns to use as groups. Groups can overlap with fields.

#groups = 'company, os'

# Comma seperated string providing additional table columns to add as host vars to each inventory host.

#fields = 'company, os, os_version'
EOF

Step 2. Login to Ansible Tower and add a custom inventory under Settings -> Inventory Scripts -> ADD. For the custom script go get the  now.py

Step 3. Go create an inventory under Inventory -> ADD -> Inventory

Step 4. Then click on Sources and add

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 -> Configure Tower -> Jobs -> Extra Environment Variables

 

Step 6. You are now ready to sync. Click on the sync button

Step 7. If your sync was successful you should see the following under jobs