-
Notifications
You must be signed in to change notification settings - Fork 2k
"service: enabled=yes" do not enable systemd service #3764
Comments
Same problem here with supervisor. Walk around this problem by using this task
Server Ubuntu 16.04 LTS, |
@grossws, ping. This issue is still waiting on your response. |
Actually that's pretty easy to fix I hit this issue with zabbix-agent on debian 8 jessie with systemd with latest ansible release 2.1.1.0 zabbix-agent package has both sysv's /etc/init.d/zabbix-agent script and systemd's /lib/systemd/system/zabbix-agent.service service there is a code in service.py: (rc, out, err) = self.execute_command("%s is-enabled %s" % (self.enable_cmd, service_name,))
if rc == 0:
return True
elif sysv_exists(service_name):
return sysv_is_enabled(service_name)
else:
return False ie it checks if service is-enabled in systemd and then if it's enabled in sysv for example: but, if you have both: this patch fixes issue for me: --- service.py.orig 2016-08-11 12:32:00.000000000 +0300
+++ service.py 2016-08-11 12:56:31.000000000 +0300
@@ -496,6 +496,8 @@
(rc, out, err) = self.execute_command("%s is-enabled %s" % (self.enable_cmd, service_name,))
if rc == 0:
return True
+ elif out.startswith('disabled'):
+ return False
elif sysv_exists(service_name):
return sysv_is_enabled(service_name)
else: ie if 'systemctl is-enabled foo' returns 'disabled\n', then report it's 'disabled' |
+1 |
when both unit file and sysv init script exist fixes ansible#3764 also see ansible@92b4ae4
when both unit file and sysv init script exist fixes ansible#3764 also see ansible@92b4ae4
Nice! This is happening with many other services as well, for example, instead of running:
I have to run:
Then, it works! With the patch applied against my local Ansible, problem solved! Sevice module back to business. Please, make this change available on Ansible's Ubuntu PPA! :-D |
+1 Agreed this bug is very annoying |
+1 |
Reproduced in ansible 2.2.1.0 |
I worked around by having two steps:
The disable step fixes enough state for the enable step to work properly Was super annoying to find this issue. |
My worked aroud is |
To everyone that still has this issue despite it being fixed this is probably because of ansible/ansible#22303. If the service action plugin detects an OS using systemd the service task does not use the service module but the systemd module unless you set the As a workaround until the bug is fixed you can use: - name: Enalbe my service
service:
name: myservice
enabled: True
use: service While this is still a workaround it's a lot cleaner than just calling systemctl directly or disabling and the reenabling the service. |
Currently, there appears to be an issue with Ansible in which, if a service is already enabled with sysvinit, the service will not be enabled with Ansible. This appears to be the condition with this repository; likely, the upstream package is bringing in the sysvinit script (as it's not being deployed by ansible) and enabling it. This commit implements a workaround as documented ansible/ansible-modules-core#3764 (comment). While, confusingly, the package is "using" the sysvinit style service tool for enabling the service, systemd implements a compatibility layer that allows enabling it via this shim. This correctly enables the service. See ansible/ansible#22303 See geerlingguy/ansible-role-php@84ab337
- ansible service/systemd module fails to enable some services - ansible/ansible-modules-core#3764 - geerlingguy/ansible-role-varnish#65
ISSUE TYPE
COMPONENT NAME
service module
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
OS X 10.11.5
Managed OS: ubuntu 16.04
SUMMARY
"service: enabled=yes" do not enable systemd service in case when service is disabled in systemd and at the same time enabled in sysvinit scripts
STEPS TO REPRODUCE
Task:
Service is disabled in systemd:
At the same time service is enabled in sysvinit:
EXPECTED RESULTS
Make service zabbix-server enabled - service should start on boot:
ACTUAL RESULTS
Ansible task do not enable service. Task finished with
changed: false
status:The text was updated successfully, but these errors were encountered: