ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.06k stars 3.42k forks source link

Ansible Tower - Servicenow integration Failed #2515

Closed hd2212 closed 6 years ago

hd2212 commented 6 years ago
ISSUE TYPE
COMPONENT NAME
SUMMARY

I'm basically following the steps mentioned in ansible servicenow integration official repo to integrate servicenow and get hosts from CMDB. I have all the dependencies installed ( python-configparser) and my ansible version is 2.7.0 and my tower version is 3.3.0 . I have the now.ini file in my /etc/ansible directory and also my now.py script. I have pasted the contents of now.py in my custom script contents in tower. Created an inventory and used the custom script in sources. I have all the credentials set up and also enabled .ini, script plugins in ansible.cfg file . When i'm trying to sync the inventory I'm facing the below error. Could anyone please help me out with resolving this problem? Please find the error below [WARNING]: * Failed to parse /tmp/awx_69_rRSdgQ/tmpZkM0LD with script plugin: Inventory script (/tmp/awx_69_rRSdgQ/tmpZkM0LD) had an execution error: Traceback (most recent call last): File "/tmp/awx_69_rRSdgQ/tmpZkM0LD", line 321, in main(sys.argv) File "/tmp/awx_69_rRSdgQ/tmpZkM0LD", line 316, in main inventory.generate() File "/tmp/awx_69_rRSdgQ/tmpZkM0LD", line 205, in generate content = self._invoke('GET', path, None) File "/tmp/awx_69_rRSdgQ/tmpZkM0LD", line 155, 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: //ap i/now/table/cmdb_ci_server?sysparm_exclude_reference_link=true&sysparmdisplay value=true&sysparm_fields=sys_class_name,fqdn,ip_address,name,host_name (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConne ction object at 0x7f9fc37e23d0>: Failed to establish a new connection: [Errno -2] Name or service not known',)) [WARNING]: Unable to parse /tmp/awx_69_rRSdgQ/tmpZkM0LD as an inventory source ERROR! No inventory was parsed, please check your configuration and options.

ADDITIONAL INFORMATION

Link to the now.py file. https://github.com/ServiceNowITOM/ansible-sn-inventory/blob/master/now.py

wenottingham commented 6 years ago
HTTPSConnectionPool(host='none', port=443): Max retries exceeded with url: //ap
i/now/table/cmdb_ci_server?sysparm_exclude_reference...

You appear to not be passing the host correctly.

hd2212 commented 6 years ago

you mean the servicenow instance name like your_instance.service-now.com?

wenottingham commented 6 years ago

Yes - however you're supposed to pass it to that script, it doesn't look like it made it through.

hd2212 commented 6 years ago

I'm using the now.ini file where I placed it in our tower cluster servers in the /etc/ansible/ directory so that it will help the script to pull the instance, username and password from the file. So you think the problem is with the credentials?

wenottingham commented 6 years ago

If you're not passing the NOW_INI env variable, it does not look like it will look in /etc/ansible... only in the current working directory.

hd2212 commented 6 years ago

Got it! Thanks much!

wenottingham commented 6 years ago

Sure. Closing this, feel free to reopen if you run across an AWX bug in the process of using it.

hd2212 commented 6 years ago

Hey I have the script running on my unix server and i'm able to fetch the hostnames from the cmdb server when i run the commands ansible -i now.py all -m ping and ./now.py --list, but i'm still facing the same error in the tower even after specifying the "NOW_INI":"/etc/ansible/now.ini" in extra environment variables. What can be possibly going wrong?

wenottingham commented 6 years ago

Is job isolation enabled?

hd2212 commented 6 years ago

Yes

hd2212 commented 6 years ago

Also my tower is an elb which contains two tower servers as one cluster. So is there a chance that might be causing the problem? . But it shouldn't as i'm using the elb to hit the cluster.

wenottingham commented 6 years ago

If you're using Tower, please contact your RH support rep.

hd2212 commented 6 years ago

Hey I got it working on Tower as well, but do you have any idea how the filtering of hosts is done on tower?. Because I just need a set of hosts and not the whole pool of hosts.