ansible - 在没有 ansible.cfg 的情况下运行 Ansible 设置模块

标签 ansible windows-subsystem-for-linux

我想通过声明特定主机来运行 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/

相关文章:

docker - 无法通过 tcp ://localhost:2375 连接到 Docker 守护程序

ruby-on-rails - 为在 WSL 环境中运行的 Rails 项目配置 capybara 时,如何指定 chrome.exe 的路径?

ssh - 如何防止 Vagrant 询问 ssh key 密码

redis - WSL Redis 遇到 System has not been booted with systemd as init system (PID 1)。不能操作

json - 通过将 dict2items 和 JMESPath 与 ansible 结合,从复杂的 json 查询键

string - 将字符串分解为最大长度子字符串列表的 Ansible 最佳实践?

ansible - 您如何在Ansible Tower中同时执行一项以上的工作?

linux - 使用 Ansible 迭代从 Docker API 返回的 json

mongodb - 在 ubuntu wsl2 systemd 上安装 MongoDB 问题 systemd 作为 init 系统(PID 1)

loops - Ansible 2.7.5 |错误! 'set_fact'不是Play的有效属性