# Ansible trying to use "initctl" with CentOS 7

**URL:** <https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330>\
**Category:** Ansible Project\
**Created:** [January 20, 2015, 6:58pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330 "2015-01-20T18:58:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RJ\_Nowling](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@RJ\_Nowling](https://forum.ansible.com/u/RJ_Nowling)\
**Post date:** [January 20, 2015, 6:58pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330/1 "2015-01-20T18:58:18Z")

</div>

Hi all,

I’m using Ansible with CentOS 7 images in Vagrant.

I have the following task:

- name: restart iptables  
action: service name=iptables state=restarted  
when: is\_centos

When it is run on the images, I get:

failed: [slave0] =\> {“failed”: true, “parsed”: false}  
SUDO-SUCCESS-vukmjpqjkiplzemawuntmvtspyydtpot  
{“msg”: “[Errno 2] No such file or directory”, “failed”: true, “cmd”: “initctl version”, “rc”: 2}  
{“msg”: “[Errno 2] No such file or directory”, “failed”: true, “cmd”: “None show None”, “rc”: 2}

CentOS 6 used upstart (initctl) but CentOS 7 uses systemd (systemctl). I’m not sure why Ansible is picking the wrong method. I’m using Ansible 1.8.2 (from the CentOS RPMs.).

Has anyone seen anything like this? Any tips on getting Ansible to identify the right service method?

Thanks,  
RJ

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [January 21, 2015, 2:41pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330/2 "2015-01-21T14:41:42Z")

</div>

can you try using current devel, many fixes on detection were made there.

---

<div class="post-metadata">

**Author:** ![RJ\_Nowling](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@RJ\_Nowling](https://forum.ansible.com/u/RJ_Nowling)\
**Post date:** [January 21, 2015, 4:36pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330/3 "2015-01-21T16:36:55Z")

</div>

Thanks, Brian!

Problem seems to be solved in the devel branch.

---

<div class="post-metadata">

**Author:** ![Jeremy\_Eder](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jeremy\_Eder](https://forum.ansible.com/u/Jeremy_Eder)\
**Post date:** [February 27, 2015, 8:05pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330/4 "2015-02-27T20:05:49Z")

</div>

yep fixed in dev. this means that the version in epel7 cannot actually manage rhel7 machines 🙂

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [March 5, 2015, 3:22pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330/5 "2015-03-05T15:22:06Z")

</div>

Hmm… I’ll talk to nirik ( Kevin Fenzi, the EPEL maintainer) about whether it makes sense to backport the module to the EPEL package.

-Toshio

---

<div class="post-metadata">

**Author:** ![RJ\_Nowling](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@RJ\_Nowling](https://forum.ansible.com/u/RJ_Nowling)\
**Post date:** [March 5, 2015, 3:38pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330/6 "2015-03-05T15:38:14Z")

</div>

Part of the issue was that I was trying to manage a service that was in CentOS 6, but not CentOS 7. (Firewall services were changed.) When it failed to find the service in systemd and couldn’t, it fell back to initctl. When I updated to devel, this was caught and handled correctly.

So, the older version of ansible works with CentOS 7 / RHEL 7 – it’s just that the detection mechanisms are leaky.

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [March 5, 2015, 4:31pm UTC](https://forum.ansible.com/t/ansible-trying-to-use-initctl-with-centos-7/17330/7 "2015-03-05T16:31:03Z")

</div>

Ah I see -- yeah, if it's just the error reporting is wrong it might  
not be worthwhile to backport a change in the EPEL package.

-Toshio
