ansible - Shell 模块失败但原始模块工作.. 在 Ansible
问题描述
我的客户端机器是 5.11 和 python 版本 2.7 但它仍然失败
root@00047BLRSANDEEPC:/mnt/e/Ansible-project/Solarwind/systems_swiagent_install/tests# ansible -i hosts all -m shell -a "cat /etc/redhat-release"
10.XX.XX.XX | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to 10.XX.XX.XX closed.\r\n",
"module_stdout": " File \"/root/.ansible/tmp/ansible-tmp-1561087764.46-1054359176771/AnsiballZ_command.py\", line 39\r\n with open(module, 'wb') as f:\r\n ^\r\nSyntaxError: invalid syntax\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
工作 -->
root@00047BLRSANDEEPC:/mnt/e/Ansible-project/Solarwind/systems_swiagent_install/tests# ansible -i hosts all -m raw -a "cat /etc/redhat-release"
10.XX.XX.XX | CHANGED | rc=0 >>
CentOS release 5.11 (Final)
Shared connection to 10.XX.XX.XX closed.
解决方案
原始模块不需要安装 python。因此,它提供了所需的输出。
运行 shell 命令时,无法在该远程主机上检测到 python。尝试在 PATH 变量中设置 python 可执行文件。ansible -i hosts all -m shell -a "export PATH=<python_installed_location>:$PATH && cat /etc/redhat-release"
如果可行,请尝试在 PATH 变量中设置 python,然后运行所有命令。
推荐阅读
- php - 如何从 Laravel 5.8 中的动态按钮传递正确的数据
- html - 通过将鼠标悬停在子元素上来影响父元素
- visual-studio-code - 如何停止VS。破坏我的代码格式的代码?
- git - 如何推送文件并在之后忽略它
- javascript - 我们如何在反应原生的两个选项卡更改上更新单个状态
- angular - 如何加载 config.json 并在另一个模块中使用配置值?
- mockito - 如何模拟自定义 util 类
- php - CakePHP 2.9 连接查询返回错误结果
- r - R:在 matlib 中使用 Solve 求解方程组,其中 #unknowns > # eqns
- docker - 在 Dockerfile 上为 Kibana 定义 ELASTICSEARCH_URL