I am uninstalling several packages with the apt module, explicitly marking them as purged, as seen on the snippet below. Ansible successfully removes these packages. However, when I log into the machine and open aptitude, these packages are purged but marked for installation. Is there a way to prevent this?
name: Ensure several blacklisted packages are uninstalled
apt: pkg={{ item }} state=absent purge=yes
with_items:
I’ve this happen within the last month on the command line of a system ansible had never touched. Things were a bit crazy at the time, so I may not describe the situation quite right…but it was something along the lines of I wanted postfix instead of sendmail, or rsyslog instead of sysklogd. When I would install what I wanted, apt-get would automatically remove the other package as a mutual exclusion or “alternate”. I spent a few moments trying to avoid this auto-swap (why, escapes me) with “apt-get purge -y ^sendmail*” followed by “apt-get install -y postfix”.
That worked…but when I fried up aptitude later it tried to revert the changes of both commands. Once I got it (re)sorted and happy, I just started letting it have its way on the mutual exclusions.
So my advice would be to try repeating on the command line what you’ve got in the playbook, as you might find aptitude still does this. (I do remember though, for certain, that in my case the purge was not enough… I had to also install one of the recently purged package’s alternates to make aptitude mad)