zoukankan      html  css  js  c++  java
  • 自动化运维工具ansible-如何设置客户端多python版本问题

    问题:在使用ansible进行管理客户主机时,发现客户主机安装了多个版本的python,并且默认版本为3.0

    shell>>cat list

    192.168.2.9

    shell>>ansible all -m ping -i list --ask-pass -u test

    会报如下错误信息:

    192.168.2.9 | FAILED >> {
                                           "failed": true, 
                                           "msg": "  File "/home/test/.ansible/tmp/ansible-1382616743.5-201381009945012/ping", line 340     except OSError, e:                   ^ SyntaxError: invalid syntax ",
                                           "parsed": false

                                           }

    原因很简单:python版本的不兼容性导致的语法错误;

    ansible额外提供了一个变量:ansible_python_interpreter

    添加参数:

    shell>>cat list

    192.168.2.9  ansible_python_interpreter=/usr/bin/python2.4

    shell>>ansible all -m ping -i list --ask-pass -u test

    192.168.2.9 | success >> {
        "changed": false,
        "ping": "pong"
    }

    OK返回正确的ping结果,成功运行

  • 相关阅读:
    Linux .o a .so .la .lo的区别
    linux源码Makefile详解
    Kconfig详解
    如何将驱动程序静态编译进内核
    getpeername
    Socket programming in C on Linux | tutorial
    C Socket Programming for Linux with a Server and Client Example Code
    UDP protocol
    TCP protocol
    How to learn linux device driver
  • 原文地址:https://www.cnblogs.com/simplelogic/p/3386748.html
Copyright © 2011-2022 走看看