我有问题可以使ec2.py脚本适用于动态清单。在CentOS 7Ansible ec2.py不能正常工作
安装ansible:
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum --enablerepo=epel install ansible
配置一个简单的hosts文件和SSL密钥访问。运行:
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正在工作。
安装博托。
yum --enablerepo=epel install python2-boto
从正式文档(http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script)中的链接下载ec2.py和ec2.ini。运行它我得到以下错误:
[[email protected] 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'
试图从git和pip安装ansible,与boto相同。总是得到相同的错误。
我在这里失踪了什么?
您是否尝试ec2.py脚本的'devel'版本?我最好使用https://github.com/ansible/ansible/blob/v2.3.1.0-1/contrib/inventory/ec2.py –
尝试一下,我有完全相同的问题,并使用devel版本。刚开始调试,所以没有答案,但只是一个说明我看到完全一样的你(只在Ubuntu上,Python 3.5,Ansible从PIP) –