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

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).

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

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

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

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://github.com/ansible/ansible-modules-core/issues/915

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
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=751638