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?
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.