Ansible trying to use "initctl" with CentOS 7

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

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

Thanks, Brian!

Problem seems to be solved in the devel branch.

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

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

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.

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