ansible使用yum模块提示没有yum模块

发布于 2022-09-01 19:56:07 字数 2549 浏览 17 评论 0

ansible版本:
图片描述

最开始使用ansible -m yum 出现的问题:

[root@ansible_01 ~]# ansible ansibletest -m yum -a "name=httpd state=latest"
192.168.122.13 | FAILED >> {
    "failed": true, 
    "msg": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446449048.01-255202696230448/yum\", line 27, in <module>\r\n    import yum\r\nImportError: No module named yum\r\nOpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: mux_client_request_session: master session id: 3\r\ndebug1: mux_client_request_session: master session id: 3\r\nShared connection to 192.168.122.13 closed.\r\n", 
    "parsed": false
}

192.168.122.14 | FAILED >> {
    "failed": true, 
    "msg": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446449048.01-24350147651889/yum\", line 27, in <module>\r\n    import yum\r\nImportError: No module named yum\r\nOpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: mux_client_request_session: master session id: 3\r\ndebug1: mux_client_request_session: master session id: 3\r\nShared connection to 192.168.122.14 closed.\r\n", 
    "parsed": false
}

192.168.122.12 | FAILED >> {
    "failed": true, 
    "msg": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1446449048.01-164937528200411/yum\", line 27, in <module>\r\n    import yum\r\nImportError: No module named yum\r\nOpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: mux_client_request_session: master session id: 3\r\ndebug1: mux_client_request_session: master session id: 3\r\nShared connection to 192.168.122.12 closed.\r\n", 
    "parsed": false
}

一开始以为是我升级了python,所以它没找到yum模块

于是添加“ansible_python _ interpreter”配置:
图片描述
但最后的结果还是一样:
图片描述
有哪位遇到并解决了此问题的?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧时浪漫 2022-09-08 19:56:07

ansible换成了2.x版本,咋问题都没了

[root@localhost ansible]# ansible --version
ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
[root@localhost ansible]# ansible test -m yum -a "name=lrzsz state=latest"
192.168.20.223 | SUCCESS => {
    "changed": false, 
    "msg": "", 
    "rc": 0, 
    "results": [
        "All packages providing lrzsz are up to date", 
        ""
    ]
}
192.168.20.118 | SUCCESS => {
    "changed": false, 
    "msg": "", 
    "rc": 0, 
    "results": [
        "All packages providing lrzsz are up to date", 
        ""
    ]
}
蹲墙角沉默 2022-09-08 19:56:07

1 ansible_python _ interpreter 配置为 python2.6
2 修改 /usr/bin/yum 里为 旧的python解释器的路径即可

忆悲凉 2022-09-08 19:56:07

是不是你节点机是 ubuntu, 所以识别不了 yum 模块, yum 换 apt 试试呢.

clipboard.png

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文