Ansible-安装python3-apt软件包

时间:2020-09-01 02:38:01

标签: python-3.x ansible ubuntu-18.04

使用Ubuntu 18.04Ansible 2.9, Python 3.6.9已安装python3-apt

在基本的ansible命令ansible -b all -m apt -a "name=apache2 state=latest"上 出现错误:

FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "msg": "Could not import python modules: apt, apt_pkg. Please install python3-apt package."
}

$ sudo apt-get install python3-apt

$ ansible --version
ansible 2.9.12  
python version = 3.6.9

$ python --version
Python 3.7.6

1 个答案:

答案 0 :(得分:0)

远程节点上的

/ usr / bin / python可能是python 2.x,而不是python3。正如上面Chuck所指出的,将解释器更改为python3应该可以解决问题。