apt state=absent name=XXX does not always stop the service before deleting the package #2292

DmitryKoterov opened this Issue Mar 4, 2013 · 3 comments


None yet

2 participants

E.g. on Ubuntu Server:

- name: ensure non-needed and conflicting packages are removed
  apt: pkg=$item state=absent purge=yes
    - sendmail
    - sendmail-bin
    - sendmail-base
    - sendmail-cf
    - sendmail-doc

This successfully removes sendmail, but sendmail daemon process remains in the memory and is still running, because the service is not stopped. If I add

service: name=sendmail state=stopped

before this task, it helps, but ONLY at the very first time (because next time "service" cannot find /etc/init.d/sendmail anymore - it was purged - and fails).

My proposal is one of:

  • add a flag to softly ignore (with no error messages, i.e. as OK code) missing services in "service stopped" task;
  • or add a flag to "apt" task to force service stopping before executing the real removal procedure.

Maybe this is an issue in sendmail deb package (it does not stop the daemon on removal), but I suppose there is a number of similar cases (e.g. apache2), so it could be a good ansible feature if implemented.

mpdehaan commented Mar 4, 2013

This is a package issue.

You should consider adding the service stopped with "ignore_errors: True"

@mpdehaan mpdehaan closed this Mar 4, 2013

..."lots of packages issue".

"ignore_errors: True" is not good here, because it adds a red line to the output (and possibly corrupts information during dry-run calls - I've not tested it yet). I think if a service is absent at all, it is OK to set its state as "stopped" with no errors...

mpdehaan commented Mar 5, 2013

It does not corrupt any information.

I disagree, it's important that service name typos be dealt with. If the package removal doesn't stop the service, this is a packaging info, and a workaround is going to be necessary.

@robinro robinro pushed a commit to robinro/ansible that referenced this issue Dec 9, 2016
@washingtoneg @mattclay washingtoneg + mattclay iptables: option to configure Source NAT (#2292)
* Clean up trailing whitespace

* Add `--to-source` option to allow Source NAT (fix for #2291)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment