ec2 inventory script broke with 'module' object has no attribute 'boto3_inventory_conn'

815 views
Skip to first unread message

Michael Bushey

unread,
Jun 5, 2017, 7:46:46 PM6/5/17
to Ansible Project
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
/etc/ansible$ wget 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 <module>
    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

Matt Martz

unread,
Jun 5, 2017, 7:58:29 PM6/5/17
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a36c2754-06b0-4c15-aca5-021e65a8aded%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Matt Martz
@sivel
sivel.net

Michael Bushey

unread,
Jun 5, 2017, 8:12:28 PM6/5/17
to Ansible Project

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}

Michael Bushey

unread,
Jun 5, 2017, 8:32:52 PM6/5/17
to Ansible Project
"./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

Michael Bushey

unread,
Jun 5, 2017, 9:02:17 PM6/5/17
to Ansible Project

/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 <module>
    __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 <module>
    @_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.



Vivek

unread,
Jun 15, 2017, 1:36:34 PM6/15/17
to Ansible Project
It seems working fine with ansible 2.4.0
Reply all
Reply to author
Forward
0 new messages