Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.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与AWS动态清单(ec2.py)一起使用_Python_Amazon Web Services_Amazon Ec2_Ansible_Ansible Inventory - Fatal编程技术网

Python 将Ansible与AWS动态清单(ec2.py)一起使用

Python 将Ansible与AWS动态清单(ec2.py)一起使用,python,amazon-web-services,amazon-ec2,ansible,ansible-inventory,Python,Amazon Web Services,Amazon Ec2,Ansible,Ansible Inventory,尝试使用ec2.py使用静态+动态主机文件 我尝试过以下指南: 重要的是,在下面运行此功能是有效的 ansible -m ping tag_Ansible_Test 这意味着aws cli、boto和ec2.py安装正确且正常工作 现在,在主机文件中定义以下组(如文档所示)时: [tag_Ansible_Test] [backend-test-group:children] tag_Ansible_Test 尝试对组运行ansible命令时,出现以下错误: ansible 2.4

尝试使用ec2.py使用静态+动态主机文件

我尝试过以下指南:

重要的是,在下面运行此功能是有效的

ansible -m ping tag_Ansible_Test
这意味着aws cli、boto和ec2.py安装正确且正常工作

现在,在主机文件中定义以下组(如文档所示)时:

[tag_Ansible_Test]

[backend-test-group:children]
tag_Ansible_Test

尝试对组运行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 ansible 2.4.0.0 配置文件=/etc/ansible/ansible.cfg 配置的模块搜索路径=[u'/root/.ansible/plugins/modules',u'/usr/share/ansible/plugins/modules'] ansible python模块位置=/usr/lib/python2.7/site-packages/ansible 可执行文件位置=/bin/ansible python版本=2.7.5(默认值,2015年11月20日02:00:19)[GCC 4.8.5 20150623(Red Hat 4.8.5-4)] 使用/etc/ansible/ansible.cfg作为配置文件 设置目录插件 使用脚本插件解析/etc/ansible/ec2.py清单源 [警告]:无法匹配提供的主机模式,忽略:后端测试组 [警告]:没有匹配的主机,无需执行任何操作 正在从/usr/lib/python2.7/site packages/ansible/plugins/callback/_init__;.pyc加载stdout类型的最小回调插件v2.0
我在这里遗漏了什么?

通过如下设置文件夹结构解决了问题:

/etc/ansible/combined
- hosts (the original file static+dynamic hosts file)
- ec2.py
- ec2.ini
然后,更改ansible.cfg中的
库存设置:

...
inventory       = /etc/ansible/combined
...

感谢@KonstantinSuvorov的帮助

你们是否同时提供库存(静态和动态)?@KonstantinSuvorov你们的意思是?[tag_Ansible_测试][后端测试组:儿童]tag_Ansible_测试
...
inventory       = /etc/ansible/combined
...