我是Ansible的新手。 我一直在使用以下教程来设置dynamic库存 – https://aws.amazon.com/blogs/apn/getting-started-with-ansible-and-dynamic-amazon-ec2-inventory-management/
当运行ec2.py时,出现以下错误 – 错误:清单脚本(ec2.py)有一个执行错误:Traceback(最近一次调用最后一个):文件“/etc/ansible/ec2.py”,第130行,在from boto import elasticache中ImportError:不能导入名字elasticache
任何人都可以提出什么问题?
看起来你需要安装boto模块
pip install boto
应该为你做。
在Ubuntu上(至less在12.04),似乎如果你通过PIP安装python模块, /usr/local/lib/python2.7/dist-packages不会被其他的读取 – 它只会被root用户和员工读取组
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
最简单的解决scheme是(没有权限更改dist目录)是将您的用户添加到员工组:
usermod -aG staff USERNAME
如果你从Ansible ppa安装Ansible
https://launchpad.net/~ansible/+archive/ubuntu/ansible
那么你的Ansible在你的Ubuntu中使用python 2.7软件包进行安装。
你将需要安装python-boto,你有两种方法来做到这一点:
在Ubuntu系统中安装python-boto软件包:
sudo apt-get install python-boto
在你的系统python中使用pip安装软件包boto , 不要推荐 ,避免这种情况,因为你将来从apt安装的python软件包和依赖软件包
sudo pip install boto
您好所有我运行在同一个问题。我的设置如下:
我正在运行自制软件,我试图重新安装ansible和boto,没有运气。 我不断收到错误消息:
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
寻求任何帮助。 谢谢!