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 Answers4

2

It looks like you need to install the boto module

pip install boto

should do that for you.

user9517
  • 114,104
  • 20
  • 206
  • 289
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
Rilindo
  • 5,058
  • 5
  • 26
  • 46
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

Yonsy Solis
  • 284
  • 1
  • 9
-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!

whobutsb
  • 249
  • 2
  • 3
  • 6