Closed harrydevine closed 3 years ago
The version of the script in this repository isn't Python 3 compatible. Red Hat Training uses a forked version that they've migrated to Python 3, I'll talk to them about possible updates.
Fix for except ldap.LDAPError, e: ^ SyntaxError: invalid
is in PR #7, haven't had a chance to test it yet.
I copied the updated python script to my RHEL 8 Ansible Tower, sync'ed the Inventory Script, and it succeeded. I see my IDM groups and hosts, so it looks like its working. I really appreciate your time on this!
Harry
Glad to hear it's working! Merging and closing.
I am using this script in our Ansible Tower server. It works great on RHEL 7 with Python 2.7, but on a new Tower installation on RHEL 8 and Python 3, we get the following error. Red Hat support via ticket #02770664 requested that I reach out to the script author.
Thanks, Harry
Traceback (most recent call last): File "/usr/bin/awx-manage", line 11, in
load_entry_point('awx==3.7.1', 'console_scripts', 'awx-manage')()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/init.py", line 154, in manage
execute_from_command_line(sys.argv)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, *cmd_options)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(args, *options)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 1147, in handle
raise exc
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 1037, in handle
venv_path=venv_path, verbosity=self.verbosity).load()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 215, in load
return self.command_to_json(base_args + ['--list'])
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 198, in command_to_json
self.method, proc.returncode, stdout, stderr))
RuntimeError: ansible-inventory failed (rc=1) with stdout:
stderr:
ansible-inventory 2.9.7
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, Dec 5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] Using /etc/ansible/ansible.cfg as config file host_list declined parsing /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu as it did not pass its verify_file() method auto declined parsing /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu as it did not pass its verify_file() method toml declined parsing /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu as it did not pass its verify_file() method
[WARNING]: Failed to parse /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu with script
plugin: Inventory script (/opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu) had an
execution error: File "/opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu", line 85
except ldap.LDAPError, e: ^ SyntaxError: invalid
syntax
File "/usr/lib/python3.6/site-packages/ansible/inventory/manager.py", line 280, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/lib/python3.6/site-packages/ansible/plugins/inventory/script.py", line 161, in parse
raise AnsibleParserError(to_native(e))
[WARNING]: Failed to parse /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu with yaml
plugin: Syntax Error while loading YAML. did not find expected <document
start> The error appears to be in
start> '/opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu': line
45, column 1, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: # EDIT: LDAP URI of your FreeIPA server LDAP_URI = "ldap://auth1.secure-ose.faa.gov" ^ here
File "/usr/lib/python3.6/site-packages/ansible/inventory/manager.py", line 280, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/lib/python3.6/site-packages/ansible/plugins/inventory/yaml.py", line 105, in parse
raise AnsibleParserError(e)
[WARNING]: Failed to parse /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu with ini
plugin: /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu:33: Expected key=value host variable assignment, got: json
File "/usr/lib/python3.6/site-packages/ansible/inventory/manager.py", line 280, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File "/usr/lib/python3.6/site-packages/ansible/plugins/inventory/ini.py", line 138, in parse
raise AnsibleParserError(e)
[WARNING]: Unable to parse /opt/tmp/awx_49_5i4hcrgl/tmp1uc1r_pu as an inventory source ERROR! No inventory was parsed, please check your configuration and options.