首页 > 解决方案 > 如何在具有 python 2.4 的远程服务器上进行 ansible 工作

问题描述

让我的问题更有意义...

Ansible 控制器服务器:ansible 2.4.2.0 Python 2.7.5

托管节点名 (goldville):Python 2.4.2

当我运行 #ansible goldville -m ping 时,出现以下错误

文件 "/tmp/ansible_RSjze6/ansible_module_ping.py",第 8 行\r\n from future import absolute_import, division, print_function\r\nSyntaxError: future feature absolute_import is not defined\r\n"

我如何使用这个节点和 python 2.4.2 从控制器运行剧本。

标签: ansible

解决方案


如果您想在某些主机或组中使用 python 2.4,请设置ansible_python_interpreter库存变量,请尝试以下操作:

  [py24-hosts]
  goldville-py3 ansible_host=goldville 

  [py24-hosts:vars]
  ansible_python_interpreter=/usr/bin64/python2.4

但是如果你想全部使用 python2.4,你必须在配置文件interpreter_python的部分中设置 keydefaultsansible.cfg

文档: https ://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html


推荐阅读