No inventory was parsed, please check your configuration and options

2,953 views
Skip to first unread message

Florian Bellencontre

unread,
Feb 22, 2021, 4:33:34 PM2/22/21
to AWX Project

##### SUMMARY
I've just started installing Ansible AWX and I've imported a fairly simple playbook that I'll join you later. Once all my configuration was done, I tried to launch this playbook in check mode. But it returned an error because it can't parse my inventory.

Yet this inventory is a simple INI file, containing a single host. I tried to explain my problem on IRC but nobody had a solution.

##### ENVIRONMENT
* AWX version: 17.0.1
* AWX install method: docker
* Ansible version:  2.9.17
* Operating System: Ubuntu
* Web Browser: Firefox

##### STEPS TO REPRODUCE

organization tree:
```
ansible
├── roles
│   ├── role_test
│   │   └── tasks
│   │       └── main.yml
├── playbooks
│   └── test.yml
└── toto
```

roles/role_test/main.yml
```
- name: "Recursively find /tmp files"
  find:
    paths: /tmp
    recurse: yes
  register: test
  tags: test

- name: "debug"
  debug:
    msg: "{{ test }}"
  tags: test
```

toto inventory file:
```
[test]
test ansible_host=test.domain ansible_python_interpreter=/usr/bin/python3
```

playbooks/test.yml
```
- hosts:
    - test
  roles:
    - role_test
```

##### ACTUAL RESULTS

```
Identity added: /tmp/awx_301_lctkr8ew/artifacts/301/ssh_key_data (root@ansible-awx)
ansible-playbook 2.9.17
  config file = /tmp/awx_301_lctkr8ew/project/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-playbook
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /tmp/awx_301_lctkr8ew/project/ansible.cfg as config file
[WARNING]:  * Failed to parse /tmp/awx_301_lctkr8ew/tmpffjwpj28 with
constructed plugin: We were unable to read either as JSON nor YAML, these are
the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.   did not find expected key  The error appears
to be in '/tmp/awx_301_lctkr8ew/tmpffjwpj28': line 3, column 51, but may be
elsewhere in the file depending on the exact syntax problem.  The offending
line appears to be:  # -*- coding: utf-8 -*- print('{"all": {"hosts": [],
"children": ["test"]}, "test": {"hosts": ["test"], "vars": {"ansible_host":
"wiki2.cosium.com", "ansible_python_interpreter": "/usr/bin/python3"}},
"_meta": {"hostvars": {"test": {"remote_tower_enabled": "true"}}}}')
^ here We could be wrong, but this one looks like it might be an issue with
unbalanced quotes. If starting a value with a quote, make sure the line ends
with the same set of quotes. For instance this arbitrary example:      foo:
"bad" "wolf"  Could be written as:      foo: '"bad" "wolf"'
  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/constructed.py", line 109, in parse
    self._read_config_data(path)
  File "/usr/lib/python3.6/site-packages/ansible/plugins/inventory/__init__.py", line 217, in _read_config_data
    raise AnsibleParserError(to_native(e))
[WARNING]:  * Failed to parse /tmp/awx_301_lctkr8ew/tmpffjwpj28 with ini
plugin: host range must be begin:end or begin:end:step
  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 /tmp/awx_301_lctkr8ew/tmpffjwpj28 as an inventory
source
ERROR! No inventory was parsed, please check your configuration and options.
```

##### ADDITIONAL INFORMATION

AWX inventory working
```
ansible-inventory 2.9.17
  config file = /tmp/awx_299_qz55u5v9/project/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 /tmp/awx_299_qz55u5v9/project/ansible.cfg as config file
Parsed /tmp/awx_299_qz55u5v9/project/toto inventory source with ini plugin
[WARNING]: Found both group and host with same name: test
    5.806 INFO     Processing JSON output...
    5.808 INFO     Loaded 1 groups, 1 hosts
    5.903 INFO     Inventory import completed for toto in 0.1s
```

Florian Bellencontre

unread,
Feb 26, 2021, 9:45:03 AM2/26/21
to AWX Project

Solution

Blog: https://www.ansible.com/blog/ansible-tower-feature-spotlight-custom-credentials
Go to section: "ANOTHER EXAMPLE - USING THIRD-PARTY CREDENTIAL STORAGE"

The solution is not intuitive and is not well explained in the documentation. You should not use the credentials already existing in AWX, you have to create a custom credentials to be able to perform the lookup.

Reply all
Reply to author
Forward
0 new messages