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 

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.

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

2 thoughts on “ServiceNow (snow) inventory for Ansible Tower 3.2.1

  • Hi,
    I have followed the steps for my AWX environment but this doesn’t work for me. Is there any change for AWX setup (which is deployed on Docker containers)? I get the following errors.

    [WARNING]: * Failed to parse /tmp/awx_inventory_5eidpz/tmp6p5lkH with script
    plugin: Inventory script (/tmp/awx_inventory_5eidpz/tmp6p5lkH) had an execution
    error: Traceback (most recent call last): File
    “/tmp/awx_inventory_5eidpz/tmp6p5lkH”, line 318, in main(sys.argv)
    File “/tmp/awx_inventory_5eidpz/tmp6p5lkH”, line 313, in main
    inventory.generate() File “/tmp/awx_inventory_5eidpz/tmp6p5lkH”, line 202, in
    generate content = self._invoke(‘GET’, path, None) File
    “/tmp/awx_inventory_5eidpz/tmp6p5lkH”, line 152, in _invoke ‘http’:
    self.proxy, ‘https’: self.proxy}) File
    “/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/sessions.py”,
    line 535, in get return self.request(‘GET’, url, **kwargs) File
    “/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/sessions.py”,
    line 522, in request resp = self.send(prep, **send_kwargs) File
    “/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/sessions.py”,
    line 642, in send r = adapter.send(request, **kwargs) File
    “/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/adapters.py”,
    line 503, in send raise ConnectionError(e, request=request)
    requests.exceptions.ConnectionError: HTTPSConnectionPool(host=’none’,
    port=443): Max retries exceeded with url: //api/now/table/cmdb_ci_server?syspar
    m_exclude_reference_link=true&sysparm_display_value=true&sysparm_fields=sys_cla
    ss_name,fqdn,ip_address,name,host_name (Caused by NewConnectionError(‘:
    Failed to establish a new connection: [Errno -2] Name or service not known’,))
    [WARNING]: Unable to parse /tmp/awx_inventory_5eidpz/tmp6p5lkH as an inventory
    source
    ERROR! No inventory was parsed, please check your configuration and options.

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Hit Counter provided by laptop reviews