[AWX-17.1.0] ServiceNow Inventory Plugin doesn't create host groups

Hi.

Recently I managed to configure a template that fetches CMDB from ServiceNow and it kind of works. This is the article I followed:
http://gregsowell.com/?p=6618
I added some extra keyed groups:

keyed_groups:

  • key: device_type | lower
    prefix: ‘’
    separator: ‘’
  • key: u_firmware_type | upper
    prefix: ‘’
    separator: ‘’
  • key: u_part_name2 | upper
    prefix: ‘’
    separator: ‘’
  • key: location
    prefix: ‘’
    separator: ‘’
  • key: install_status
    prefix: ‘’
    separator: ‘’

But none of them are created. See output below:

ansible-inventory 2.9.18
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/var/lib/awx/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible-inventory
python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /tmp/bwrap_212_ny01v3ue/awx_212_njxbvlnw/project/collections/requirements.yml as it did not pass its verify_file() method
script declined parsing /tmp/bwrap_212_ny01v3ue/awx_212_njxbvlnw/project/collections/requirements.yml as it did not pass its verify_file() method
[WARNING]: Skipping ‘collections’ as this is not a valid group definition
Parsed /tmp/bwrap_212_ny01v3ue/awx_212_njxbvlnw/project/collections/requirements.yml inventory source with yaml plugin
host_list declined parsing /tmp/bwrap_212_ny01v3ue/awx_212_njxbvlnw/project/snow-switch-now.yml as it did not pass its verify_file() method
script declined parsing /tmp/bwrap_212_ny01v3ue/awx_212_njxbvlnw/project/snow-switch-now.yml as it did not pass its verify_file() method
Connecting to…https://COMPANY.service-now.com//api/now/table/cmdb_ci_ip_switch?sysparm_exclude_reference_link=true&sysparm_display_value=true&sysparm_fields=sys_id,name,ip_address,operational_status,firmware_version,serial_number,u_firmware_type,device_type,u_part_name2,location,install_status&sysparm_query=
Parsed /tmp/bwrap_212_ny01v3ue/awx_212_njxbvlnw/project/snow-switch-now.yml inventory source with auto plugin
24.659 INFO Processing JSON output…
25.043 INFO Loaded 0 groups, 3555 hosts
25.609 INFO Inventory import completed for ServiceNow Switches in 1.0s

Would it be something related to the plugin itself or v17.1?

Regards,
Marek

OK, I’ll answer myself.
It seems that ServiceNow plugin prefixes all host_vars with “sn_”. Therefore I had to change keys in keyed_groups section to values saved by the plugin (i.e. I queried for field “u_firmware_type”, which has been saved as “sn_u_firmware_type”).

All groups were created afterwards.

Hopefully it’ll save people time.

BR,
Marek