ServiceNowITOM / servicenow-ansible

22 stars 28 forks source link

Does plugin work with connecting to a SNOW datbase view vs table? #33

Closed cts-dev closed 3 years ago

cts-dev commented 3 years ago

Currently on a project integrating Red Hat Ansible Tower 3.7.3 with Service Now as the inventory source. We're able to pull data directly in through SN_TABLE: cmdb_ci_server etc. However, we're unable to pull anything from a view we created SN_TABLE: u_server_linked_app_report_list

As far as the plugin is concerned, are database views treated any differently? I cannot seem to find any examples or anywhere specifically in the plugin code at first glance that would prevent the import. Thank you.

amittell commented 3 years ago

It should work as long as you are not using enhanced inventory, the plugin uses the Table API which supports database views. I would recommend using the REST API Explorer on the ServiceNow instance to see if your view returns the data you expect.

https://community.servicenow.com/community?id=community_question&sys_id=319a432ddb5cdbc01dcaf3231f9619bb

cts-dev commented 3 years ago

It should work as long as you are not using enhanced inventory, the plugin uses the Table API which supports database views. I would recommend using the REST API Explorer on the ServiceNow instance to see if your view returns the data you expect.

That's interesting. To answer your question, yes we are able to curl the data as well and we get the correct JSON output we're looking for. But Tower is refusing to import.

amittell commented 3 years ago

If you use the inventory plug-in from a command-line playbook do you see inventory returned?

willtome commented 3 years ago

You may need to define the selection_order option in your inventory file. By default, it looks to add the host to inventory by the first valid value from the fields ip_address,fqdn,host_name,name. If your database view does not have any fields with exactly those names, no hosts will be added to inventory.

willtome commented 3 years ago

Please re-open if you still have questions.