可靠的dynamic库存工作不正常

这是针对AWS使用的dynamic库存

RHEL 7.3 python2-boto-2.45.0-3.el7.noarch 

适用版本

 ansible 2.3.1.0 config file = /projects/robomation/ansible.cfg configured module search path = Default w/o overrides python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] 

我有几个资源运行,当我运行

 ec2.py --list { "_meta": { "hostvars": {} } } 

另外,当我尝试运行一些标签与主机的目标主机,我得到这个

 [WARNING]: Found both group and host with same name: localhost ... ... ... skipping: no hosts matched 

我有问题设置dynamic库存以正常工作。 我有我的ec2.ini和ec2.py文件和ec2.py被设置为可执行的,我相信我已经设置正确。 此外,命令不会返回错误,只会返回任何内容。

 [root@robomation robomation]# env | grep ANSIBLE ANSIBLE_HOSTS=/projects/robomation/inventory/ec2.py [root@robomation robomation]# env | grep EC2_INI EC2_INI_PATH=/projects/robomation/inventory/ec2.ini [root@robomation robomation]# env | grep AWS AWS_REGION=us-west-2 [root@robomation robomation]# inventory/ec2.py --list { "_meta": { "hostvars": {} } } [root@robomation robomation]# ansible --version ansible 2.3.1.0 config file = /projects/robomation/ansible.cfg configured module search path = Default w/o overrides python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] 

我如何解决dynamic库存问题?

更新:

pip freeze

 boto3==1.4.4 botocore==1.5.82 

rpm -qa | grep boto

 python2-boto-2.45.0-3.el7.noarch 

ec2.pydynamic库存使用boto对AWS进行API调用。

因此,您可能需要检查boto可以通过以下方式连接到AWS:

 python >>> import boto >>> s3 = boto.connect_s3() 

如果你得到这样的东西:

boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials

您的凭据不正确。 有几种方法来configuration博托。 但出于debugging目的,您可以通过命令行简单设置AWS_ACCESS_KEY_ID和“AWS_SECRET_ACCESS_KEY”,如下所示:

 export AWS_ACCESS_KEY_ID='AK123' export AWS_SECRET_ACCESS_KEY='abc123' 

在使用IAM roles您应该注意:

使用boto 2.5.0或更高版本时,IAMangular色由plugins / inventory / ec2.py支持。

在分配了IAMangular色的EC2实例上运行,并且angular色策略允许使用ec2:Describe *操作时,ec2.py –list将无需指定aws_access_key_id或aws_secret_access_key。

如果ec2.ini定义route53 = True或rds = True,则angular色策略中需要执行其他操作。 github问题