【发布时间】:2020-01-07 14:57:55
【问题描述】:
我正在尝试获取一个 Ansible 任务来打印在 Windows 10 上运行时使用的版本。
我目前正在尝试这样的事情:
---
# Source: https://serverfault.com/a/695798
- name: Get version
win_shell: ansible --version
register: ansibleVersion
# How I chose to expose the version collected
- name: Display version
win_msg:
msg: "Ansible Version: {{ ansibleVersion.stdout }}"
display_seconds: 30
但是,我得到了这个输出:
"stderr": "ansible : The term 'ansible' is not recognized as the name of a cmdlet, function, script file, or operable program. \r\nCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\n
完全披露,我是 Ansible 的新手。我已经尝试过win_command、win_shell,但我不确定接下来要尝试什么。
【问题讨论】:
-
我可以看到在执行 ansible 脚本的主机上无法识别/找到 ansible。如果 ansible 可执行文件存在于某个目录中,您可以将
chdir参数与win_shell模块一起使用。 -
ansible
.exe脚本正常定位在哪里? -
据我所知,Windows 没有 Ansible
.exe。您是否在 WSL 上安装了 Ansible(如此处所述:docs.ansible.com/ansible/2.5/user_guide/…)? -
Ansible 正在你的控制器上运行,你的节点上没有对应的,只有 python 运行的脚本,这就是为什么Ansible is said to be agentless
-
@IntrastellarExplorer 你试过这个解决方案了吗,它对你有用吗?
标签: windows ansible windows-10