Ansible: Could not find aptitude. Please ensure it is installed

时间:2019-11-20 08:54:18  来源:igfitidea点击:

执行ansible-playbook时,报错

fatal: [db1]: FAILED! => {"changed": false, "failed": true, "msg": " Could not find aptitude. Please ensure it is installed.}

如何在Debian或者UbuntuLinux服务器上修复此错误?

其中yml文件内容包含了:

- apt: update_cache=yes upgrade=yes

原因

远程Debian/Ubuntu的服务器上没有安装aptitude命令

解决方案

使用apt模块本身在服务器上安装aptitude并运行upgrade:

- name: Update all packages to the latest version
  apt:
    name: aptitude 
    upgrade: yes

或者upgrade命令添加dist参数,告诉它使用apt-get命令:

- name: Update all packages to the latest version
  apt:
    upgrade: dist

另一种解决方案是在.yml文件中使用以下内容:

- name: Upgrade all packages to the latest version
  apt:
    name: "*"
    state: latest