Why am I getting "Syntax Error" when running playbooks using Python 3.6 in Ansible Tower?

Solution In Progress - Updated -

Issue

While executing Ansible Playbook in Ansible Tower with Python 3.6.2, getting following error:

SSH password: 
 [WARNING]:  * Failed to parse /tmp/awx_34_I8rGcV/tmpbNIf5G with script plugin:
Inventory script (/tmp/awx_34_I8rGcV/tmpbNIf5G) had an execution error:   File
"/tmp/awx_34_I8rGcV/tmpbNIf5G", line 3     print '{"all": {"hosts":
["localhost"]}, "_meta": {"hostvars": {"localhost": {"ansible_connection":
"local"}}}}'
^ SyntaxError: Missing parentheses in call to 'print'
 [WARNING]:  * Failed to parse /tmp/awx_34_I8rGcV/tmpbNIf5G with yaml plugin:
Syntax Error while loading YAML.   expected <block end>, but found ','  The
error appears to have been in '/tmp/awx_34_I8rGcV/tmpbNIf5G': line 3, column
40, 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": ["localhost"]}, "_meta": {"hostvars": {"localhost":
{"ansible_connection": "local"}}}}'                                        ^
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"'
 [WARNING]:  * Failed to parse /tmp/awx_34_I8rGcV/tmpbNIf5G with ini plugin:
/tmp/awx_34_I8rGcV/tmpbNIf5G:3: Expected key=value host variable assignment,
got: {"all": {"hosts": ["localhost"]}, "_meta": {"hostvars": {"localhost":
{"ansible_connection": "local"}}}}
 [WARNING]: Unable to parse /tmp/awx_34_I8rGcV/tmpbNIf5G as an inventory source
ERROR! No inventory was parsed, please check your configuration and options.

Environment

Ansible Tower < 3.5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content