我想通过声明特定主机来运行 ansible 设置模块。
我使用的是 Windows 10 机器,带有安装了 ansible 的 Windows 子系统。
我可以在使用本地主机时运行安装模块,即:
ansible localhost -m setup
当使用我在一个虚拟环境中使用的 ansible.cfg 文件时,我可以针对虚拟机运行它,即:
ansible TestVm -m setup
在另一个虚拟环境中,我安装了ansible,但没有设置ansible.cfg文件,并且我的hosts.yml文件位于Windows中(不是WSL文件系统)。
无论我切换哪个目录,我都无法使用以下命令运行安装模块:
ansible -i inventory -m setup
.
有没有一种方法可以在没有配置文件的情况下运行安装程序,如果是的话,我缺少调用的哪一部分?
最佳答案
试试这个:
ansible all -i inventory -m setup
其中 list 是至少包含 hosts.yml 文件的目录。
这是hosts.yml的示例
all:
hosts:
192.168.2.9:
192.168.2.3:
192.168.2.4:
此外,在其中任何一个之前,您必须添加 pywinrm:
pip install pywinrm
关于ansible - 在没有 ansible.cfg 的情况下运行 Ansible 设置模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57241438/