CFEngine 3.6 tries to understand if a Linux is using systemd as init system by looking at the contents of /proc/1/cmdline
, that happens in bundle common inventory_linux
. That’s indeed a smart thing to do but unfortunately fails on Debian Jessie, where you have:
root@cf-test-v10:~# ls -l /sbin/init lrwxrwxrwx 1 root root 20 May 26 06:07 /sbin/init -> /lib/systemd/systemd
the pseudo-file in /proc
will still report /sbin/init
and as a result the systemd
class won’t be set. This affects services promises negatively and therefore I needed to make our policies try to outsmart the inventory 😉 These promises, added in a bundle of ours, did the trick:
bundle common debian_info { vars: init_is_link:: "init_link_destination" string => filestat("/sbin/init","linktarget") ; classes: init_is_link:: "systemd" expression => regcmp("/lib/systemd/systemd", "$(init_link_destination)"), comment => "Check if /sbin/init links to systemd" ; debian:: "init_is_link" expression => islink("/sbin/init"), comment => "Detect if init is a link" ; }
Notice that our bundle is actually bigger, I cut off all the promises that were not relevant for this post. Enjoy!