Sam*_*m-T 9 python-3.x ansible ubuntu-18.04
使用Ubuntu 18.04, Ansible 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
小智 18
进入python3 dist-package目录
cd /usr/lib/python3/dist-packages
然后链接这两个文件
sudo ln -s apt_inst.cpython-35m-x86_64-linux-gnu.so apt_inst.so
sudo ln -s apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so