[英]Using Ansible with AWS dynamic inventory (ec2.py)
Trying to use static+dynamic hosts file using ec2.py.尝试使用 ec2.py 使用静态+动态主机文件。
I've tried following guides:我试过以下指南:
Its important to say that running this below is working!重要的是要说在下面运行它是有效的!
ansible -m ping tag_Ansible_Test
Meaning aws-cli, boto and ec2.py installed correctly and working.意思是 aws-cli、boto 和 ec2.py 已正确安装并正常工作。
Now, when defining the following groups (as documented) in hosts file:现在,在 hosts 文件中定义以下组(如文档所述)时:
[tag_Ansible_Test]
[backend-test-group:children]
tag_Ansible_Test
ansible -m ping backend-test-group -vvvv
When trying to run ansible command with the group, I get the following error:尝试对组运行 ansible 命令时,出现以下错误:
ansible 2.4.0.0 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /bin/ansible python version = 2.7.5 (default, Nov 20 2015, 02:00:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] Using /etc/ansible/ansible.cfg as config file setting up inventory plugins Parsed /etc/ansible/ec2.py inventory source with script plugin [WARNING]: Could not match supplied host pattern, ignoring: backend-test-group [WARNING]: No hosts matched, nothing to do Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc
What am I missing here?我在这里缺少什么?
Problem solved by setting a folder structure as follows:通过如下设置文件夹结构解决的问题:
/etc/ansible/combined
- hosts (the original file static+dynamic hosts file)
- ec2.py
- ec2.ini
Then, altering the inventory
setting in ansible.cfg:然后,更改 ansible.cfg 中的inventory
设置:
...
inventory = /etc/ansible/combined
...
Thanks to @KonstantinSuvorov for helping out with that!感谢@KonstantinSuvorov 帮助解决这个问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.