F
F
Fdrsmrdv2020-08-27 13:43:04
ubuntu
Fdrsmrdv, 2020-08-27 13:43:04

How to properly remove packages from Ubuntu using Ansible?

Task:

Remove Docker from ubuntu server.

sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli 
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce


My code:

- name: Remove packages
    remote_user: fsmrdv
    apt: name={{ packages_to_uninstall }} autoremove=yes purge=yes


Problem:

If one of the packages is not installed, Ansible throws an error.

What needs to be added to the code to ignore the error or check for packages?
Thanks in advance :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
chupasaurus, 2020-08-27
@chupasaurus

You got state=absentunstuck

S
Sasha Sancho, 2020-08-27
@KPEBA

What exactly is the error? It is interesting to see what kind of error (for understanding)

P
Puma Thailand, 2020-08-27
@opium

Well, you first install these packages and then delete

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question