fatal: [db1]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Could not find aptitude. Please ensure it is installed.“}
My yml file includes the following line:
- apt: update_cache=yes upgrade=yes
How do I fix this error on a Debian or Ubuntu Linux server?
You need to use apt module to manage packages for Debian/Ubuntu Linux using ansible. The apt module runs command depends upon upgrade parameter as follows:
apt module syntax
The syntax is:
- name: Update all packages to the latest version apt: upgrade: VALUE
Where VALUE can be any one of the following:
- if upgrade parameter is no (upgrade=no) – Do NOT upgrade anything (default)
- if upgrade parameter is yes (upgrade=yes) – Do upgrade using the aptitude command
- if upgrade parameter is safe (upgrade=safe) – Do upgrade using the aptitude command
- if upgrade parameter is full (upgrade=full) – Do upgrade using the aptitude command
- if upgrade parameter is dist (upgrade=dist) – Do upgrade using the apt-get command
Understanding the error
The following error indicates that you do not have aptitude command installed on the remote Debian/Ubuntu box which is quite common on virtual private servers (VPS) or cloud servers or minimal installation or customized installation:
TASK [Updating host using apt] *********************************************************************************************** fatal: [db1]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find aptitude. Please ensure it is installed."} fatal: [db2]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find aptitude. Please ensure it is installed."} fatal: [www1]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find aptitude. Please ensure it is installed."} fatal: [www2]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find aptitude. Please ensure it is installed."}
You can verify that by ssh into any one of the server:
$ ssh user@db1 type -a aptitude
bash: line 0: type: aptitude: not found
$ ssh vivek@server1.cyberciti.biz aptitude
bash: aptitude: command not found
How do I fix this problem?
To fix this problem either install aptitude on the remote box using apt module itself and run upgrade:
- name: Update all packages to the latest version apt: name: aptitude upgrade: yes
Or pass the dist parameter to the upgrade so that it will use apt-get command:
- name: Update all packages to the latest version apt: upgrade: dist
Another solution is to use the following in your .yml file:
- name: Upgrade all packages to the latest version apt: name: "*" state: latest
For more info see apt – Manages apt-packages documentations.
🐧 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |