更新
不记得我是如何修复它的,但似乎只是因为 ec2.py 脚本的权限错误。
我有一些使用动态库存设置Ansible
部署的剧本。AWS EC2
ansible-playbook
在服务器内部使用时效果很好
ansible-playbook setup.yml
它处于打开状态Ubuntu 14.04
并Ansible
2.0.1.0
具有默认值/etc/ansible/ansible.cfg
[defaults]
remote_user = ubuntu
hostfile = /etc/ansible/ec2.py
host_key_checking = False
我得到ec2.py
了ec2.ini
http://docs.ansible.com/ansible/intro_dynamic_inventory.html
Jenkins
使用此插件触发剧本时https://wiki.jenkins-ci.org/display/JENKINS/Ansible+Plugin
它返回有关的错误,ec2.py
因为它认为主机文件是ini
文件
ERROR! The file /etc/ansible/hosts is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this with `chmod -x /etc/ansible/hosts`.
Inventory script (/etc/ansible/hosts) had an execution error: Traceback (most recent call last):
File "/etc/ansible/hosts", line 1328, in <module>
Ec2Inventory()
File "/etc/ansible/hosts", line 177, in __init__
self.do_api_calls_update_cache()
File "/etc/ansible/hosts", line 424, in do_api_calls_update_cache
self.get_instances_by_region(region)
File "/etc/ansible/hosts", line 469, in get_instances_by_region
conn = self.connect(region)
File "/etc/ansible/hosts", line 440, in connect
conn = self.connect_to_aws(ec2, region)
File "/etc/ansible/hosts", line 458, in connect_to_aws
conn = module.connect_to_region(region, **connect_args)
File "/usr/local/lib/python2.7/dist-packages/boto/ec2/__init__.py", line 66, in connect_to_region
return region.connect(**kw_params)
File "/usr/local/lib/python2.7/dist-packages/boto/regioninfo.py", line 187, in connect
return self.connection_cls(region=self, **kw_params)
File "/usr/local/lib/python2.7/dist-packages/boto/ec2/connection.py", line 103, in __init__
profile_name=profile_name)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1100, in __init__
provider=provider)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 569, in __init__
host, config, self.provider, self._required_auth_capability())
File "/usr/local/lib/python2.7/dist-packages/boto/auth.py", line 989, in get_auth_handler
'Check your credentials' % (len(names), str(names)))
boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials
/etc/ansible/hosts:3: Error parsing host definition ''''': No closing quotation
如果我使用该选项Inline content
,Dynamic inventory
那么它会使用这样的随机.ini
文件
/usr/local/bin/ansible-playbook /data/ansible-playbooks/setup.yml -i /tmp/inventory487543089183487870.ini -f 5
[WARNING]: provided hosts list is empty, only localhost is available
以前有人遇到过这个问题吗?