Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Ansible ec2.py不工作_Python_Amazon Web Services_Ansible - Fatal编程技术网

Python Ansible ec2.py不工作

Python Ansible ec2.py不工作,python,amazon-web-services,ansible,Python,Amazon Web Services,Ansible,我很难让它在ec2.py脚本中运行以进行动态库存 已在CentOS 7上安装ansible: yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum --enablerepo=epel install ansible 配置简单的主机文件和ssl密钥访问。运行ansible: ansible all -m ping 获取预期的输出。Ansible正在工作 已安装的aws cli

我很难让它在ec2.py脚本中运行以进行动态库存

已在CentOS 7上安装ansible:

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum --enablerepo=epel install ansible
配置简单的主机文件和ssl密钥访问。运行ansible:

ansible all -m ping
获取预期的输出。Ansible正在工作

已安装的aws cli:

wget -q https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
unzip awscli-bundle.zip
./awscli-bundle/install -i /opt/aws -b /usr/bin/aws
在~/.aws中配置凭据文件。运行aws:

aws ec2 describe-instances
获取预期的输出。Aws cli正在工作

安装boto

yum --enablerepo=epel install python2-boto
从官方文档()中的链接下载了ec2.py和ec2.ini。运行它时,会出现以下错误:

[root@vm09 ansible]# ./ec2.py --list
Traceback (most recent call last):
  File "./ec2.py", line 1642, in <module>
    Ec2Inventory()
  File "./ec2.py", line 193, in __init__
    self.do_api_calls_update_cache()
  File "./ec2.py", line 525, in do_api_calls_update_cache
    self.get_instances_by_region(region)
  File "./ec2.py", line 615, in get_instances_by_region
    self.add_instance(instance, region)
  File "./ec2.py", line 934, in add_instance
    if self.group_by_platform:
AttributeError: 'Ec2Inventory' object has no attribute 'group_by_platform'
[root@vm09ansible]#/ec2.py——列表
回溯(最近一次呼叫最后一次):
文件“/ec2.py”,第1642行,在
Ec2Inventory()
文件“/ec2.py”,第193行,在__
self.do\u api\u调用\u更新\u缓存()
do_api_calls_update_cache中第525行的文件“/ec2.py”
self.get_实例按_区域(区域)
文件“/ec2.py”,第615行,按区域获取实例
self.add_实例(实例,区域)
文件“/ec2.py”,第934行,在add_实例中
如果self.group\u by\u平台:
AttributeError:“Ec2Inventory”对象没有“group\u by\u platform”属性
尝试从git和pip安装ansible,与boto相同。总是得到同样的错误


这里我遗漏了什么?

好的,那么如果你看看引入了
groupby\u平台
功能的公关:

您可以看到,代码遍历了分组选项的可能属性。这些属性在脚本的更高层可用:

setattr循环迭代的列表中缺少按平台分组属性。加上它,它就会起作用

这实际上已修复(两小时前):


从git中获取最新版本,它应该可以工作。

您是否尝试了ec2.py脚本的
devel
version?我最好尝试一下,因为我有完全相同的问题,并且正在使用devel版本。刚刚开始调试,所以还没有答案,但是有一个提示说我看到的和你完全一样(仅在Ubuntu上,使用Python3.5,Ansible from pip),更新的ec2.py正在我的安装中工作。他也在Ubuntu上工作。非常感谢。