Hi, I’m trying to import a static inventory file into AWX for use with an openshift installation. This is failing when ran from AWX Web UI (or playbook present in UI) but the same command imports successfully when run directly in the container.
Setup :
Ansible AWX 1.0.6.41
Running in containers hosted on openshift 3.7
The pod has a persistent volume mounted as /ansible-data
Newly created inventory file resides under /ansible-data/inventory-files//hosts-inventory
I will have multiple new inventory files being created when jobs are submitted to awx therefore do not want the inventory files to be kept under version control.
Running the following command on the container runs fine and imports the hosts and vars successfully.
sh-4.2$ awx-manage inventory_import --source=/ansible-data/inventory-files/ --inventory-name= -v 3
Running the command in a playbook to call awx-manage results in the following output :
“_ansible_parsed”: true,
“stderr_lines”: [
" 1.554 INFO Updating inventory 4: “,
" 1.701 DEBUG Using system install of ansible-inventory CLI: /usr/bin/ansible-inventory”,
" 1.701 INFO Reading Ansible inventory source: /ansible-data/inventory-files/“,
“Traceback (most recent call last):”,
" File "/usr/bin/awx-manage", line 9, in ”,
" load_entry_point(‘awx==1.0.6.41’, ‘console_scripts’, ‘awx-manage’)()“,
" File "/usr/lib/python2.7/site-packages/awx/init.py", line 109, in manage”,
" execute_from_command_line(sys.argv)“,
" File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/init.py", line 364, in execute_from_command_line”,
" utility.execute()“,
" File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/init.py", line 356, in execute”,
" self.fetch_command(subcommand).run_from_argv(self.argv)“,
" File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv”,
" self.execute(*args, **cmd_options)“,
" File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute”,
" output = self.handle(*args, **options)“,
" File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 990, in handle”,
" self.is_custom)“,
" File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 241, in load_inventory_source”,
" is_custom=is_custom).load()“,
" File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 176, in load”,
" data = self.command_to_json(base_args + [‘–list’])“,
" File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 159, in command_to_json”,
" self.method, proc.returncode, stdout, stderr))",
“RuntimeError: ansible-inventory failed (rc=1) with stdout:”,
“”,
“stderr:”,
“\u001b[1;35m [WARNING]: * Failed to parse /ansible-data/inventory-\u001b[0m”,
“\u001b[1;35mfiles//hosts-inventory with script plugin:\u001b[0m”,
“\u001b[1;35mproblem running /ansible-data/inventory-files/\u001b[0m”,
“\u001b[1;35m/hosts-inventory --list ([Errno 8] Exec format error)\u001b[0m”,
“\u001b[1;35m\u001b[0m”,
“\u001b[1;35m [WARNING]: Unable to parse /ansible-data/inventory-\u001b[0m”,
“\u001b[1;35mfiles/<inv-name/hosts-inventory as an inventory source\u001b[0m”,
“\u001b[1;35m\u001b[0m”,
“\u001b[1;35m [WARNING]: Unable to parse /ansible-data/inventory-\u001b[0m”,
“\u001b[1;35mfiles/ as an inventory source\u001b[0m”,
“\u001b[1;35m\u001b[0m”,
“\u001b[0;31mERROR! No inventory was parsed, please check your configuration and options.\u001b[0m”
],
“changed”: true,
“end”: “2018-08-28 15:29:28.827340”,
“_ansible_no_log”: false,
“stdout”: “”,
“cmd”: “awx-manage inventory_import --source=/ansible-data/inventory-files// --inventory-name= -v 3”,
“rc”: 1,
“start”: “2018-08-28 15:29:25.575474”,
This appears similar to the following issue : https://github.com/ansible/awx/issues/1885