Cannot run my inventory script in AWX

Hello , I have an issue with the execution of my plabooks on AWX.
I use the API glpi : https://github.com/unistra/ansible-inventory-glpi in order to connect that with AWX.

With the documentation its runs very well in my local server .

I decided to test them on AWX.
I have an errror when i run the script in AWX.
Can someone help me please to reslove this issue ?

the inventory script : glpi-api.py
the playbook which returns the information : glpi-api.yml
My error :

ERROR! A playbook must be a list of plays, got a <class ‘ansible.parsing.yaml.objects.AnsibleMapping’> instead

12

13
The error appears to be in ‘/tmp/awx_609_892b858g/project/exemples/glpi-api.yml’: line 5, column 1, but may

14
be elsewhere in the file depending on the exact syntax problem.

15

16
The offending line appears to be:

17

18

Iirc awx does not run the inventory sync at run time. It does it in the inventory section like an import.

thanks for your feedback, the sync was not done !
My error :

2.599 INFO Updating inventory 3: inventory GTO

2
3.116 DEBUG Using base command: python /usr/bin/ansible-inventory -i /tmp/awx_597_mkurx6t1/tmpjcrdkdhj --playbook-dir /tmp/awx_597_mkurx6t1 -vvvvv

3
3.116 INFO Reading Ansible inventory source: /tmp/awx_597_mkurx6t1/tmpjcrdkdhj

4
3.118 INFO Using VIRTUAL_ENV: /var/lib/awx/venv/ansible

5
3.118 INFO Using PATH: /var/lib/awx/venv/ansible/bin:/var/lib/awx/venv/awx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

6
3.118 INFO Using PYTHONPATH: /var/lib/awx/venv/ansible/lib/python3.6/site-packages:

7
Traceback (most recent call last):

8
File “/var/lib/awx/venv/awx/bin/awx-manage”, line 8, in

9
sys.exit(manage())

10
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/init.py”, line 152, in manage

11
execute_from_command_line(sys.argv)

12
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/init.py”, line 381, in execute_from_command_line

13
utility.execute()

14
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/init.py”, line 375, in execute

15
self.fetch_command(subcommand).run_from_argv(self.argv)

16
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py”, line 323, in run_from_argv

17
self.execute(*args, **cmd_options)

18
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/django/core/management/base.py”, line 364, in execute

19
output = self.handle(*args, **options)

20
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/management/commands/inventory_import.py”, line 1157, in handle

21
raise exc

22
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/management/commands/inventory_import.py”, line 1047, in handle

23
venv_path=venv_path, verbosity=self.verbosity).load()

24
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/management/commands/inventory_import.py”, line 215, in load

25
return self.command_to_json(base_args + [‘–list’])

26
File “/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/management/commands/inventory_import.py”, line 198, in command_to_json

27
self.method, proc.returncode, stdout, stderr))

28
RuntimeError: ansible-inventory failed (rc=1) with stdout:

30
stderr:

31
ansible-inventory 2.9.3

32
config file = /etc/ansible/ansible.cfg

33
configured module search path = [‘/var/lib/awx/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]

34
ansible python module location = /usr/lib/python3.6/site-packages/ansible

35
executable location = /usr/bin/ansible-inventory

36
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]

37
Using /etc/ansible/ansible.cfg as config file

38
setting up inventory plugins

39
host_list declined parsing /tmp/awx_597_mkurx6t1/tmpjcrdkdhj as it did not pass its verify_file() method

40
auto declined parsing /tmp/awx_597_mkurx6t1/tmpjcrdkdhj as it did not pass its verify_file() method

41
toml declined parsing /tmp/awx_597_mkurx6t1/tmpjcrdkdhj as it did not pass its verify_file() method

42
[WARNING]: * Failed to parse /tmp/awx_597_mkurx6t1/tmpjcrdkdhj with script

43
plugin: Inventory script (/tmp/awx_597_mkurx6t1/tmpjcrdkdhj) had an execution

44
error: usage: tmpjcrdkdhj [-h] [–glpi-url GLPI_URL]

45
[–glpi-usertoken GLPI_USERTOKEN] [–glpi-apptoken

46
GLPI_APPTOKEN] [–config-file GROUPS_CONFIG_PATH] (–list |

47
–host HOST) tmpjcrdkdhj: error: the following arguments are required: --glpi-

48
url, --glpi-usertoken, --glpi-apptoken

49

50
File “/usr/lib/python3.6/site-packages/ansible/inventory/manager.py”, line 280, in parse_source

51
plugin.parse(self._inventory, self._loader, source, cache=cache)

52
File “/usr/lib/python3.6/site-packages/ansible/plugins/inventory/script.py”, line 161, in parse

53
raise AnsibleParserError(to_native(e))

54

55
[WARNING]: * Failed to parse /tmp/awx_597_mkurx6t1/tmpjcrdkdhj with yaml

56
plugin: Syntax Error while loading YAML. did not find expected <document

57

The error appears to be in ‘/tmp/awx_597_mkurx6t1/tmpjcrdkdhj’: line 4,

58
column 3, but may be elsewhere in the file depending on the exact syntax

59
problem. The offending line appears to be: “”"Ansible dynamic inventory for

60
GLPI REST API.“”" ^ here

61

62
File “/usr/lib/python3.6/site-packages/ansible/inventory/manager.py”, line 280, in parse_source

63
plugin.parse(self._inventory, self._loader, source, cache=cache)

64
File “/usr/lib/python3.6/site-packages/ansible/plugins/inventory/yaml.py”, line 105, in parse

65
raise AnsibleParserError(e)

66

67
[WARNING]: * Failed to parse /tmp/awx_597_mkurx6t1/tmpjcrdkdhj with ini

68
plugin: /tmp/awx_597_mkurx6t1/tmpjcrdkdhj:6: Expected key=value host variable

69
assignment, got: os

70

71
File “/usr/lib/python3.6/site-packages/ansible/inventory/manager.py”, line 280, in parse_source

72
plugin.parse(self._inventory, self._loader, source, cache=cache)

73
File “/usr/lib/python3.6/site-packages/ansible/plugins/inventory/ini.py”, line 138, in parse

74
raise AnsibleParserError(e)

75

76
[WARNING]: Unable to parse /tmp/awx_597_mkurx6t1/tmpjcrdkdhj as an inventory

77
source

78

79
ERROR! No inventory was parsed, please check your configuration and options.