# ec2 inventory script broke with 'module' object has no attribute 'boto3\_inventory\_conn'

**URL:** <https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655>\
**Category:** Ansible Project\
**Tags:** ubuntu, aws\
**Created:** [June 5, 2017, 11:46pm UTC](https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655 "2017-06-05T23:46:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Bushey](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Michael\_Bushey](https://forum.ansible.com/u/Michael_Bushey)\
**Post date:** [June 5, 2017, 11:46pm UTC](https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655/1 "2017-06-05T23:46:46Z")

</div>

Hello,

I am running Ubuntu 16.04 w/Ansible 2.0.0.2-2ubuntu1.

/etc/ansible$ wget [https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py)  
/etc/ansible$ wget [https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.ini](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.ini)  
/etc/ansible$ chmod +x /etc/ansible/ec2.py

I have a credentials file in ~/.aws/credentials

/etc/ansible$ ./ec2.py --list  
Traceback (most recent call last):  
File “./ec2.py”, line 1600, in   
Ec2Inventory()  
File “./ec2.py”, line 193, in **init**  
self.do\_api\_calls\_update\_cache()  
File “./ec2.py”, line 527, in do\_api\_calls\_update\_cache  
self.get\_rds\_instances\_by\_region(region)  
File “./ec2.py”, line 633, in get\_rds\_instances\_by\_region  
client = ec2\_utils.boto3\_inventory\_conn(‘client’, ‘rds’, region, \*\*self.credentials)  
AttributeError: ‘module’ object has no attribute ‘boto3\_inventory\_conn’

I have installed boto and boto3 via both apt-get and pip with the same result.  
I have found a few other versions of ec2.py but none of them work.

Any ideas?  
Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 5, 2017, 11:57pm UTC](https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655/2 "2017-06-05T23:57:55Z")

</div>

The ec2.py inventory is not fully self contained and relies on functionality within ansible itself.

The file you pulled from github requires ansible 2.3 to function.

---

<div class="post-metadata">

**Author:** ![Michael\_Bushey](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Michael\_Bushey](https://forum.ansible.com/u/Michael_Bushey)\
**Post date:** [June 6, 2017, 12:12am UTC](https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655/3 "2017-06-06T00:12:28Z")

</div>

I installed the latest Ansible (2.3.1.0) from source and now I get:

/etc/ansible$ ./ec2.py --list --refresh-cache

{“msg”: “Error: Module unable to decode valid JSON on stdin. Unable to figure out what parameters were passed”, “failed”: true}

---

<div class="post-metadata">

**Author:** ![Michael\_Bushey](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Michael\_Bushey](https://forum.ansible.com/u/Michael_Bushey)\
**Post date:** [June 6, 2017, 12:32am UTC](https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655/4 "2017-06-06T00:32:51Z")

</div>

“./ec2.py --list” is now working. The correct ec2.py was from ansible-2.3.1.0/contrib/inventory/

Thanks for your help Matt. 🙂

Michael

---

<div class="post-metadata">

**Author:** ![Michael\_Bushey](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@Michael\_Bushey](https://forum.ansible.com/u/Michael_Bushey)\
**Post date:** [June 6, 2017, 1:02am UTC](https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655/5 "2017-06-06T01:02:16Z")

</div>

/etc/ansible/ec2.py --list works, but if I try to run from ansible I get this:

~/ansible/playbooks$ ansible -i /etc/ansible/ec2.py -u ubuntu us-east-1d -m ping  
Traceback (most recent call last):  
File “/usr/local/bin/ansible”, line 4, in   
**import** (‘pkg\_resources’).run\_script(‘ansible==2.3.1.0’, ‘ansible’)  
File “/usr/lib/python2.7/dist-packages/pkg\_resources/ **init**.py”, line 2927, in   
@\_call\_aside  
File “/usr/lib/python2.7/dist-packages/pkg\_resources/ **init**.py”, line 2913, in \_call\_aside  
f(\*args, \*\*kwargs)  
File “/usr/lib/python2.7/dist-packages/pkg\_resources/ **init**.py”, line 2940, in \_initialize\_master\_working\_set  
working\_set = WorkingSet.\_build\_master()  
File “/usr/lib/python2.7/dist-packages/pkg\_resources/ **init**.py”, line 635, in \_build\_master  
ws.require( **requires** )  
File “/usr/lib/python2.7/dist-packages/pkg\_resources/ **init**.py”, line 943, in require  
needed = self.resolve(parse\_requirements(requirements))  
File “/usr/lib/python2.7/dist-packages/pkg\_resources/ **init**.py”, line 829, in resolve  
raise DistributionNotFound(req, requirers)  
pkg\_resources.DistributionNotFound: The ‘pycrypto\>=2.6’ distribution was not found and is required by ansible

I installed the python-pycryptopp packge but that didn’t help.

---

<div class="post-metadata">

**Author:** ![Vivek](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Vivek](https://forum.ansible.com/u/Vivek)\
**Post date:** [June 14, 2017, 1:55am UTC](https://forum.ansible.com/t/ec2-inventory-script-broke-with-module-object-has-no-attribute-boto3-inventory-conn/24655/6 "2017-06-14T01:55:14Z")

</div>

It seems working fine with ansible 2.4.0
