2

I am new to Ansible. I had been using the following tutorial to set up dynamic inventory- https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/

While running ec2.py, I am getting the following error- ERROR: Inventory script (ec2.py) had an execution error: Traceback (most recent call last): File "/etc/ansible/ec2.py", line 130, in from boto import elasticache ImportError: cannot import name elasticache

Can anyone suggest what is going wrong?

4 Answers 4

2

It looks like you need to install the boto module

pip install boto

should do that for you.

0

On Ubuntu (at least on 12.04), it appears that if you install python modules via PIP, /usr/local/lib/python2.7/dist-packages will not readable to other - it will just be readable to root user and staff group

drwxr-s---  6 root staff  4096 Jan  7 22:04 awscli
drwxr-s---  2 root staff  4096 Jan  7 22:04 awscli-1.9.17.dist-info
drwxr-s---  6 root staff  4096 Dec 28 22:07 beaver
drwxr-s---  2 root staff  4096 Dec 28 22:07 Beaver-31-py2.7.egg-info
drwxr-s--- 57 root staff  4096 Dec 28 22:07 boto
drwxr-s---  2 root staff  4096 Dec 28 22:07 boto-2.38.0.dist-info
drwxr-s---  5 root staff  4096 Jan  7 21:54 botocore
drwxr-s---  2 root staff  4096 Jan  7 21:54 botocore-1.3.17.dist-info

The simplest solution would be (without making permission changes to dist directory) is to add your user to staff group:

usermod -aG staff USERNAME
0

if you install Ansible from Ansible ppa

https://launchpad.net/~ansible/+archive/ubuntu/ansible

then your Ansible is installed using the python 2.7 package in your Ubuntu.

you will need python-boto installed, you have two ways to do this:

  1. install the python-boto package in your Ubuntu system:

    sudo apt-get install python-boto

  2. install the package boto using pip in your system python, NOT RECOMMENDED, avoid this because you will have future conflicts between python packages installed from apt as dependencies and packages installed with pip

    sudo pip install boto

-1

Hello All I"m running in to this same issue. My Set up is as the following:

  • Mac OSX 10.11.6
  • Python 2.7.13
  • Ansible 2.3.0.0
  • boto 2.46.1

I'am running homebrew, and I have tried reinstalling both ansible and boto with no luck. I keep receiving the error message:

ERROR! Attempted to execute "inventories/ec2.py" as inventory script: Inventory script (inventories/ec2.py) had an execution error: Traceback (most recent call last): File "/Users/myname/Sites/admin/ansible/inventories/ec2.py", line 130, in <module> from boto import elasticache ImportError: cannot import name elasticache

Looking for any assistance. Thank you!

2
  • Figured it out. Boto was installed in the root user and not my user. To resolve run: pip install --user boto.
    – whobutsb
    May 2, 2017 at 18:53
  • I flagged -1 because you used answers for putting your question, this section is to answer the question Jun 2, 2018 at 19:13

You must log in to answer this question.