运行 没有 ansible.cfg 的 Ansible 安装模块
Running Ansible setup module without an ansible.cfg
我想 运行 ansible 设置模块,通过声明一个特定的主机。
我正在使用 Windows 10 台机器,windows 子系统用于安装了 ansible 的 linux。
我可以运行使用本地主机时的设置模块,即:
ansible localhost -m setup
我可以 运行 使用我在一个虚拟环境中针对虚拟机使用的 ansible.cfg 文件时,即:
ansible TestVm -m setup
在另一个虚拟环境中,我在没有设置 ansible.cfg 文件的情况下安装了 ansible,我的 hosts.yml 文件位于 windows(不是 WSL 文件系统)中。
无论我切换到哪个目录,我都无法运行设置模块使用例如:
ansible -i inventory -m setup
.
有没有办法 运行 在没有配置文件的情况下进行设置,如果可以,我缺少调用的哪一部分?
试试这个:
ansible all -i inventory -m setup
清单是至少包含 hosts.yml 文件的目录。
这是 hosts.yml
的一个例子
all:
hosts:
192.168.2.9:
192.168.2.3:
192.168.2.4:
此外,您必须在任何这些之前添加 pywinrm:
pip install pywinrm
我想 运行 ansible 设置模块,通过声明一个特定的主机。
我正在使用 Windows 10 台机器,windows 子系统用于安装了 ansible 的 linux。
我可以运行使用本地主机时的设置模块,即:
ansible localhost -m setup
我可以 运行 使用我在一个虚拟环境中针对虚拟机使用的 ansible.cfg 文件时,即:
ansible TestVm -m setup
在另一个虚拟环境中,我在没有设置 ansible.cfg 文件的情况下安装了 ansible,我的 hosts.yml 文件位于 windows(不是 WSL 文件系统)中。
无论我切换到哪个目录,我都无法运行设置模块使用例如:
ansible -i inventory -m setup
.
有没有办法 运行 在没有配置文件的情况下进行设置,如果可以,我缺少调用的哪一部分?
试试这个:
ansible all -i inventory -m setup
清单是至少包含 hosts.yml 文件的目录。
这是 hosts.yml
的一个例子all:
hosts:
192.168.2.9:
192.168.2.3:
192.168.2.4:
此外,您必须在任何这些之前添加 pywinrm:
pip install pywinrm