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).
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
What version of Ansible are you using?
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.
Ok when you say checking from EPEL I think you mean the version from ansible, not acpid?
We’ll look into it.
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)
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
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!
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
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!