0

I'm trying to follow this to fetch inventory in us-east-1 region. I downloaded the EC2 External Inventory script and made it executable. My ~/.boto looks like following.

[Credentials]
aws_access_key_id = <ACCESS_KEY>
aws_secret_access_key = <SECRET_KEY>

Where <ACCESS_KEY> and <SECRET_KEY> have real aws access and secret key values respectively.

When I run following command I get an error instead of list nodes in the region.

$ ansible -i ec2.py -u ubuntu us-east-1 -m ping

  File "/home/waseem/Repositories/Learning/Ansible/ec2.py", line 168
    print data_to_print
                      ^
SyntaxError: invalid syntax

ERROR: failed to parse executable inventory script results: {'msg': '', 'failed': True, 'parsed': False}

What am I doing wrong?

4
  • What version of Python do you have? This looks like an issue with Python, not Ansible - Python 3 removed the simple print statement (docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function)
    – Kyle
    Aug 9, 2014 at 19:24
  • @kyl191 I have 3.4.1. Which version of Python is recommended with ansible?
    – Waseem
    Aug 9, 2014 at 19:28
  • As per docs.ansible.com/intro_installation.html, at this point, any Python 2.6+ version - python.org says 2.7.8 is the latest
    – Kyle
    Aug 9, 2014 at 19:32
  • No problem, glad to help. I've rewritten the comments as an answer, it would be nice if you marked it as accepted. Thanks!
    – Kyle
    Aug 11, 2014 at 17:45

1 Answer 1

3

This is an issue with the wrong version of Python being used, not with Ansible itself.

http://docs.ansible.com/intro_installation.html specifies that Ansible runs on Python 2.6+, not Python 3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.