CentOS 5. ansible_python_interpreter = / usr / bin / python26。还是不能用yum:module

时间:2018-01-24 18:17:10

标签: python linux ansible

仍然需要保留一些CentOS5主机,他们将yum配置为使用像https://hastebin.com/ojopevanas.ini这样的CentOS保管库仓库。在主机上使用yum时工作正常。 然而,当我尝试使用ansible时,例如:

   - name: "Install OS packages"
     yum: pkg={{item}} state=installed
     with_items: 
       - dos2unix
       - vim 

我得到"msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this module"

注意:主机在default24旁边安装了python26 在库存文件中,主机名旁边有ansible_python_interpreter = / usr / bin / python26(否则ansible甚至不能-m ping)。其他ansible任务适用于此主机

2 个答案:

答案 0 :(得分:2)

prototype模块需要class Dummy { dummy () {} } let { configurable, writable, enumerable } = Object.getOwnPropertyDescriptor(Dummy.prototype, 'dummy'); console.log('configurable', configurable); console.log('enumerable', enumerable); console.log('writable', writable); Python模块,该模块由yum包提供。在您的系统上,这是为Python 2.4安装的;你还没有为Python 2.6安装它。这是一个必须从源代码编译的二进制模块(它是rpm分发的一部分)。

如果您需要支持CentOS 5,最简单的解决方案可能是使用rpm模块代替rpm-python模块:

command

答案 1 :(得分:1)

由于使用本机yum:ansible模块无法轻易解决问题,因此我就是这样做的:

- block:                                                                                                                                
    - debug: msg="Special actions for centos 5,  vault and epel repo"                                                             
    - copy:                                                                                                                             
        src: "CentOS-Vault.repo"                                                                                                        
        dest: /etc/yum.repos.d/CentOS-Vault.repo                                                                                        
    - copy:                                                                                                                             
        src: "epel-release-5-4.noarch.rpm"                                                                                              
        dest: /tmp/epel-release-5-4.noarch.rpm                                                                                          
    - shell: "rpm -ivh /tmp/epel-release-5-4.noarch.rpm"                                                                                
      ignore_errors: true                                                                                                               
      register: epelrpmres                                                                                                              
      changed_when: "'is already installed' not in epelrpmres.stderr"                                                                   
    - shell: >                                                                                                                          
        yum --disablerepo=* --enablerepo=C5*,epel* -y install                                                                           
        dos2unix moreutils vim-minimal vim-enhanced tmux tcping                                                                         
        rsync openssh-clients htop screen tar                                                                                           
      register: yumresult                                                                                                               
      changed_when: "'Nothing to do' not in yumresult.stdout"                                                                           
  when: "ansible_distribution_major_version in ['5']" 

希望这能帮助其他人......