[英]Ansible Dynamic Inventory fails to get vagrant hosts
Trying to invoke Ansible using dynamic inventory. 尝试使用动态广告资源调用Ansible。 Created a .py script to get vagrant box information and the output is .json. 创建了一个.py脚本来获取无用信息框信息,并且输出为.json。 Below is the picture showing that 下面的图片显示
python dynamic_inventory.py --list
returns the .json python dynamic_inventory.py --list
返回.json Ansible version 1.9.2 Ansible版本1.9.2
I guess there is no shebang line at the beginning of the script. 我想脚本的开头没有shebang行。 Add one line this: 在此添加一行:
#!/usr/bin/env python
Ansible dynamic inventory script can be off any kind of executable script, not just Python. Ansible动态清单脚本可以关闭任何类型的可执行脚本,而不仅仅是Python。 So Ansible doesn't run this with python dynamic_scripts.py
, rather it uses shebang line to determine the script type. 因此Ansible不会使用python dynamic_scripts.py
运行它,而是使用shebang行来确定脚本类型。 That's why you are getting the error even though the script is executable. 因此,即使脚本是可执行的,您也会收到错误消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.