# Starting sysv service when systemd is installed

**URL:** <https://forum.ansible.com/t/starting-sysv-service-when-systemd-is-installed/26295>\
**Category:** Ansible Project\
**Created:** [December 14, 2017, 6:36pm UTC](https://forum.ansible.com/t/starting-sysv-service-when-systemd-is-installed/26295 "2017-12-14T18:36:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Weber1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Jacob\_Weber1](https://forum.ansible.com/u/Jacob_Weber1)\
**Post date:** [December 14, 2017, 6:36pm UTC](https://forum.ansible.com/t/starting-sysv-service-when-systemd-is-installed/26295/1 "2017-12-14T18:36:09Z")

</div>

Say my target machine has an OS running systemd, like CentOS 7, and I want to start a sysv service in /etc/init.d.

These tickets suggest I pass use=service to the service module:

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

[https://github.com/ansible/ansible/issues/25440](https://github.com/ansible/ansible/issues/25440)

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’"

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 14, 2017, 6:42pm UTC](https://forum.ansible.com/t/starting-sysv-service-when-systemd-is-installed/26295/2 "2017-12-14T18:42:59Z")

</div>

service module uses systemd if detected, its not a sysvinit module,  
that is here [https://github.com/ansible/ansible/pull/29158](https://github.com/ansible/ansible/pull/29158), in any  
case, systemd is supposed to be able to handle init scripts.

---

<div class="post-metadata">

**Author:** ![Jacob\_Weber1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Jacob\_Weber1](https://forum.ansible.com/u/Jacob_Weber1)\
**Post date:** [December 14, 2017, 6:51pm UTC](https://forum.ansible.com/t/starting-sysv-service-when-systemd-is-installed/26295/3 "2017-12-14T18:51:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 14, 2017, 6:54pm UTC](https://forum.ansible.com/t/starting-sysv-service-when-systemd-is-installed/26295/4 "2017-12-14T18:54:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jacob\_Weber1](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@Jacob\_Weber1](https://forum.ansible.com/u/Jacob_Weber1)\
**Post date:** [December 14, 2017, 7:06pm UTC](https://forum.ansible.com/t/starting-sysv-service-when-systemd-is-installed/26295/5 "2017-12-14T19:06:09Z")

</div>

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.
