# "bug" in service module: failing to disable (enabled=no) legacy sysv services on systemd target

**URL:** <https://forum.ansible.com/t/bug-in-service-module-failing-to-disable-enabled-no-legacy-sysv-services-on-systemd-target/17964>\
**Category:** Ansible Project\
**Created:** [April 12, 2015, 8:25pm UTC](https://forum.ansible.com/t/bug-in-service-module-failing-to-disable-enabled-no-legacy-sysv-services-on-systemd-target/17964 "2015-04-12T20:25:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [April 12, 2015, 8:25pm UTC](https://forum.ansible.com/t/bug-in-service-module-failing-to-disable-enabled-no-legacy-sysv-services-on-systemd-target/17964/1 "2015-04-12T20:25:35Z")

</div>

Hi,

I'm not entirely sure whether this should be considered an ansible or  
systemctl bug.  
This email mainly targets of making others aware of this problem.

If you want to disable (enabled=no) a service on a systemd host which  
is still using legacy sysv init.d scripts, ansible will fail to do so.  
Systemd in general has a certain degree of backwards compatibility for  
such services.

I had a short look in service.py (ansible v1.9.0.1-1).  
The module executes  
systemctl is-enabled \<service\>  
in line 486 to

I you do this for a legacy service you will get:

"Failed to get unit file state for FOO.service: No such file or director  
y"  
(retval=1)

I guess this is why ansible believes the service is disabled already,  
if it would actually run 'systemctl disable' on this service it would  
achieve what one would expect: (manually invoked)

systemctl disable tor  
Synchronizing state for tor.service with sysvinit using update-rc.d...  
Executing /usr/sbin/update-rc.d tor defaults  
Executing /usr/sbin/update-rc.d tor disable  
insserv: warning: current start runlevel(s) (empty) of script `tor'  
overrides LSB defaults (2 3 4 5).  
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script  
`tor' overrides LSB defaults (0 1 6).

---

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [April 12, 2015, 9:03pm UTC](https://forum.ansible.com/t/bug-in-service-module-failing-to-disable-enabled-no-legacy-sysv-services-on-systemd-target/17964/2 "2015-04-12T21:03:23Z")

</div>

I asked systemd-devel about is-enabled support for legacy services:

[http://lists.freedesktop.org/archives/systemd-devel/2015-April/030652.ht](http://lists.freedesktop.org/archives/systemd-devel/2015-April/030652.ht)  
ml

---

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [April 13, 2015, 8:22am UTC](https://forum.ansible.com/t/bug-in-service-module-failing-to-disable-enabled-no-legacy-sysv-services-on-systemd-target/17964/3 "2015-04-13T08:22:59Z")

</div>

for the record, this is a known debian systemd bug that affects  
ansible's service module:

[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751638](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751638)

---

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [April 13, 2015, 8:43am UTC](https://forum.ansible.com/t/bug-in-service-module-failing-to-disable-enabled-no-legacy-sysv-services-on-systemd-target/17964/4 "2015-04-13T08:43:36Z")

</div>

> for the record, this is a known debian systemd bug that affects  
> ansible's service module:
> 
> [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751638](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751638)

[https://github.com/ansible/ansible-modules-core/issues/915](https://github.com/ansible/ansible-modules-core/issues/915)

---

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [April 29, 2015, 7:55pm UTC](https://forum.ansible.com/t/bug-in-service-module-failing-to-disable-enabled-no-legacy-sysv-services-on-systemd-target/17964/5 "2015-04-29T19:55:47Z")

</div>

just in case other are also stumbling over this debian systemd bug,  
this was my temporary workaround until debian fixes this issue:

[https://github.com/nusenu/ansible-relayor/commit/efabec452f715b884528e70](https://github.com/nusenu/ansible-relayor/commit/efabec452f715b884528e70)  
a9b1e012051692acd

if you want to track the debian bug entries:  
[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=705254](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=705254)  
[https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751638](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751638)
