ServiceNow dynamic inventory
To create and manage device inventory via plugin, several steps are required. This guide covers the ServiceNow plugin.
Related reading: ServiceNow inventory plugin
Install the plugin
There is an ansible-galaxy command that can install the plugin into the IAG server. You will likely have to incorporate this command into your IAG build plan so that you do not have to do this as a manual step. For ServiceNow the command looks like this:
ansible-galaxy collection install servicenow.servicenow
Configure Ansible to use the plugin
There are several ways to accomplish this step. Below is a suggested method for enabling a plugin. Make sure the interpreter_python is appropriate for the environment.
/etc/ansible/ansible.cfg
This example enables the ServiceNow dynamic inventory plugin.
Configure the host file
Use the ServiceNow documentation to determine the most appropriate way to configure the plugin to connect to and query from the source of truth system. The configuration of the ServiceNow plugin below connects to the public ServiceNow, applies the filters, and returns all devices found there.
Be sure to specify the host file as a .yml file.
/opt/automation-gateway/ansible/inventory/hosts.yml
- If using the standard table, you can remove the line
table: "cmdb_ci_ip_switch". - For
filter_results, you are creating a filter based on ServiceNow rules to show the devices that you need. - For
compose: ansible_network_os, you are using Jinja2 expressions.