# service enable/disable not working on fresh systemd debian install

**URL:** <https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444>\
**Category:** Ansible Project\
**Created:** [September 10, 2013, 9:53am UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444 "2013-09-10T09:53:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aurelien](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@aurelien](https://forum.ansible.com/u/aurelien)\
**Post date:** [September 10, 2013, 9:53am UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/1 "2013-09-10T09:53:12Z")

</div>

Hi all,

I’m trying to use ansible to handle services on a fresh Debian Wheezy on which I installed and enabled systemd (by following [these instructions](https://wiki.debian.org/Systemd/Packaging)).

Using the service module, start/stop seems to be working ok, example below :

$ ansible […] -m service -a “name=acpid state=stopped”  
success \>\> {  
“changed”: true,  
“name”: “acpid”,  
**“state”: “stopped”**  
}

then :

# systemctl status acpid.service

acpid.service - ACPI event daemon  
Loaded: loaded (/lib/systemd/system/acpid.service; enabled)  
Active: **inactive (dead)** since Tue, 10 Sep 2013 11:31:41 +0200; 4min 19s ago

But when it comes to service enabling/disabling, it does not seem to be working although ansible says the change was successful:

$ ansible […] -m service -a “name=acpid enabled=false”  
success \>\> {  
“changed”: true,  
**“enabled”: false,**  
“name”: “acpid”  
}

still, the service stays enabled in systemd:

# systemctl is-enabled acpid.service

**enabled**

Maybe it’s because ansible first tries to use another tool like update-rc.d instead of systemctl ?  
Or is there something wrong with my setup… ?

Thanks

Aurélien

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 10, 2013, 12:36pm UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/2 "2013-09-10T12:36:20Z")

</div>

What version of Ansible are you using?

---

<div class="post-metadata">

**Author:** ![aurelien](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@aurelien](https://forum.ansible.com/u/aurelien)\
**Post date:** [September 10, 2013, 12:59pm UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/3 "2013-09-10T12:59:44Z")

</div>

I’m using the last version from git checkout :  
ansible 1.3 (devel 808d9596b2) last updated 2013/09/10 10:27:35 (GMT +200)

tried also with the last version available from EPEL on CentOS (ansible 1.2.3) but the result is the same.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 10, 2013, 1:58pm UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/4 "2013-09-10T13:58:55Z")

</div>

Ok when you say checking from EPEL I think you mean the version from ansible, not acpid?

We’ll look into it.

---

<div class="post-metadata">

**Author:** ![aurelien](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@aurelien](https://forum.ansible.com/u/aurelien)\
**Post date:** [September 10, 2013, 2:37pm UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/5 "2013-09-10T14:37:40Z")

</div>

Yes I was talking about installing ansible from EPEL.

I did some more tests.  
I tried creating a dummy systemd unit in /etc/systemd/system/testd.service.  
This time, using Ansible to enable/disable the service worked perfectly.

Next step, I created also a dummy old-fashion init script in /etc/init.d/testd,  
and added a symlink in /etc/rc5.d… after that I could not use Ansible anymore to enable/disable the service.

So I guess this confirms my first guess…

(I did these last tests with the latest ansible from git)

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 10, 2013, 4:13pm UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/6 "2013-09-10T16:13:47Z")

</div>

The underlying issue here is that when Ansible sees the update-rc.d binary, it assumes the services will be managed either through upstart or sysV. I’ve created a patch to add in a check for systemctl-managed services, so that it will use the proper binary to manage the service:

[https://gist.github.com/jimi1283/8094ebdebc3af54dd4c3](https://gist.github.com/jimi1283/8094ebdebc3af54dd4c3)

If you could give this some testing and confirm it fixes your issues, I will get it merged in to the development branch today.

Thanks!

---

<div class="post-metadata">

**Author:** ![aurelien](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@aurelien](https://forum.ansible.com/u/aurelien)\
**Post date:** [September 10, 2013, 5:15pm UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/7 "2013-09-10T17:15:14Z")

</div>

Hi James,

I have just applied the patch, tried to disable/enable several systemd-managed services using the service module and now it’s working.  
That was fast, thanks a lot !

Aurélien

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 10, 2013, 5:45pm UTC](https://forum.ansible.com/t/service-enable-disable-not-working-on-fresh-systemd-debian-install/13444/8 "2013-09-10T17:45:55Z")

</div>

Excellent, I had already done a bit more testing too and went ahead and merged this in, so it will be included in 1.3.

Thanks for catching this and reporting it!
