Thanks Alan but I’m getting below error while syncing.
stderr: ERROR! Could not parse inventory source /tmp/awx_inventory_xxxqxc/tmptERboz with available plugins: Plugin script failed: failed to parse executable inventory script results from /tmp/awx_inventory_xxxqxc/tmptERboz: needs to be a json dict Plugin yaml failed: Syntax Error while loading YAML.
exception type: <class ‘yaml.scanner.ScannerError’> exception: mapping values are not allowed in this context
AND
2018-01-09 22:39:36,609 INFO awx.main.commands.inventory_import Reading Ansible inventory source: /tmp/awx_inventory_aJYV3F/tmpYicPAz Traceback (most recent call last): File “/opt/awx/bin/awx-manage”, line 11, in sys.exit(manage()) File “/opt/awx/embedded/lib/python2.7/site-packages/awx/init.py”, line 109, in manage execute_from_command_line(sys.argv) File “/opt/awx/embedded/lib64/python2.7/site-packages/django/core/management/init.py”, line 364, in execute_from_command_line utility.execute() File “/opt/awx/embedded/lib64/python2.7/site-packages/django/core/management/init.py”, line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File “/opt/awx/embedded/lib64/python2.7/site-packages/django/core/management/base.py”, line 283, in run_from_argv self.execute(*args, **cmd_options) File “/opt/awx/embedded/lib64/python2.7/site-packages/django/core/management/base.py”, line 330, in execute output = self.handle(*args, **options) File “/opt/awx/embedded/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py”, line 993, in handle self.is_custom) File “/opt/awx/embedded/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py”, line 242, in load_inventory_source is_custom=is_custom).load() File “/opt/awx/embedded/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py”, line 177, in load data = self.command_to_json(base_args + [‘–list’]) File “/opt/awx/embedded/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py”, line 160, in command_to_json self.method, proc.returncode, stdout, stderr)) RuntimeError: ansible-inventory failed (rc=4) with stdout: stderr: ERROR! Could not parse inventory source /tmp/awx_inventory_aJYV3F/tmpYicPAz with available plugins: Plugin script failed: failed to parse executable inventory script results from /tmp/awx_inventory_aJYV3F/tmpYicPAz: needs to be a json dict Plugin yaml failed: YAML inventory has invalid structure, it should be a dictionary, got: <class ‘ansible.parsing.yaml.objects.AnsibleUnicode’> Plugin ini failed: /tmp/awx_inventory_aJYV3F/tmpYicPAz:3: Expected key=value host variable assignment, got: json
Do you have any example handy for tower-cli? I’ll try to work with that as well…
Could you provide your custom inventory script that results in the errors below?
Alan’s mental code should use print json.dumps(r) for the last line. Without the print there would be no output, which would of course fail to be parsed as either JSON or YAML.