首页 > ansible使用yum模块提示没有yum模块

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

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”配置:

但最后的结果还是一样:

有哪位遇到并解决了此问题的?


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", 
        ""
    ]
}

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


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

【热门文章】
【热门文章】