Starting sysv service when systemd is installed

189 views
Skip to first unread message

Jacob Weber

unread,
Dec 14, 2017, 1:36:09 PM12/14/17
to Ansible Project
Say my target machine has an OS running systemd, like CentOS 7, and I want to start a sysv service in /etc/init.d.

This used to work on Ansible 2.2, but no longer seems to work in 2.4. Is there a different way?

- name: start foo service

  service: name=foo state=started enabled=yes use=service


This returns an error:


systemd could not find the requested service \"'foo'\"

Brian Coca

unread,
Dec 14, 2017, 1:43:18 PM12/14/17
to Ansible Project
service module uses systemd if detected, its not a sysvinit module,
that is here https://github.com/ansible/ansible/pull/29158, in any
case, systemd is supposed to be able to handle init scripts.



--
----------
Brian Coca

Jacob Weber

unread,
Dec 14, 2017, 1:51:41 PM12/14/17
to Ansible Project
So is that "use" parameter no longer valid? It should probably be removed from the documentation. I didn't see this mentioned in the Ansible 2.4 changelog or porting guide.

Brian Coca

unread,
Dec 14, 2017, 1:54:47 PM12/14/17
to Ansible Project
The use parameter is still valid, it lets you override the selection,
but the 'use=service' defaults to the 'old ansible service module' ,
which still does it's own autodetection and uses systemd if present
(it always did).

It does NOT use the 'service' command, which varies by distro/OS and
has diff implementations, though the service plugin can use it, it is
not what the `use` parameter does.



--
----------
Brian Coca

Jacob Weber

unread,
Dec 14, 2017, 2:06:09 PM12/14/17
to Ansible Project
I see, thanks. Not sure how I got it to work before with use=service, unless maybe the service module's auto-detection method changed since 2.2. Anyway, I guess I can work around it with "command" for now, until there's a sysv module available.
Reply all
Reply to author
Forward
0 new messages