嗨,我正在使用 ansible 任务检查 python 的版本但是我在 stderr 变量而不是 stdout 中获取输出值。
这是我检查 pthon 版本的可靠任务。
---
- shell: "python --version"
register: python_installed
Run Code Online (Sandbox Code Playgroud)
这是任务的输出:
changed: [172.17.0.3] => {
"changed": true,
"cmd": "python --version",
"delta": "0:00:00.259578",
"end": "2017-06-30 03:43:44.341772",
"invocation": {
"module_args": {
"_raw_params": "python --version",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
}
},
"rc": 0,
"start": "2017-06-30 03:43:44.082194",
"stderr": "Python 2.6.6",
"stderr_lines": [
"Python 2.6.6"
],
"stdout": "",
"stdout_lines": []
}
Run Code Online (Sandbox Code Playgroud)
我试图在可执行论证中添加 python 路径,它也失败了。我还尝试使用 shell 模块的命令模块。仍然失败
Hen*_*gel 13
就像一个注释:
Python 版本已经由setup_module收集,可以通过ansible_python_version
Run Code Online (Sandbox Code Playgroud)ansible -m setup localhost | grep ansible_python_version "ansible_python_version": "3.6.1",
归档时间: |
|
查看次数: |
11156 次 |
最近记录: |