Incorrect dynamic script source link - AWS EC2

HI Team,

On page https://ansible-docs.readthedocs.io/zh/stable-2.0/rst/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script

Link to ec2 dynamic python inventory script, i see 404 not found error. Can anyone assist me please ?

Thanks,
Parth

Nor the link - https://github.com/ansible/ansible/tree/devel/contrib/inventory works which all users on youtube vedios and web blogs used. May be domain changed ? Neither raw github user content domain worked instead github.com in this URL.

Hi Parth,

You are using docs which are not official docs. Also, EC2 external inventory script is replaced by aws_ec2 inventory plugin.

You can find it here - https://github.com/ansible-collections/amazon.aws/blob/main/plugins/inventory/aws_ec2.py

Ahh okay thanks buddy. So below link is official ansible doc site right ?

https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html

Thanks,
P

Yes, you may want to refer https://docs.ansible.com/ansible/latest/collections/amazon/aws/aws_ec2_inventory.html for aws_ec2.

Using dynamic inventory plugin - https://docs.ansible.com/ansible/latest/plugins/inventory.html#using-inventory-plugins

Has script been tested and working fine ? I am getting syntax error.

[ansible@ip-172-3xxxx dynamic_inventory]$ chmod 755 ec2.py
[ansible@ip-172-3xxxx dynamic_inventory]$ ./ec2.py
./ec2.py: line 4: syntax error near unexpected token (' ./ec2.py: line 4: from future import (absolute_import, division, print_function)’

https://github.com/ansible-collections/amazon.aws/blob/main/plugins/inventory/aws_ec2.py

Hi Parth,

  1. Where did you get ec2.py?

  2. Why are you doing chmod ?

Please refer https://docs.ansible.com/ansible/latest/plugins/inventory.html#using-inventory-plugins for using aws_ec2 dynamic inventory plugin.

Got script from link you gave of github.
For making script executable doing chmod. Isnt required ??

You can try this

https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py
https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.ini

Ashok,

I tried as i have mentioned in below mail trail, getting 404 Not found error.

Hi Partha,

Please try this

https://raw.githubusercontent.com/ansible/ansible/stable-1.9/plugins/inventory/ec2.py

ec2.py is deprecated and it is based upon a deprecated version of boto.

Please use aws_ec2 as it is based upon the latest version of a boto and provides additional features.