4 # Determine whether systemd is the init system on the node
7 # Check if the service_provider fact is systemd
10 # If you override the service provider then it will return false, even if the
11 # underlying system still is systemd.
14 # Fact: systemd_version
17 # Determine the version of systemd installed
20 # Check the output of systemctl --version
25 # Fact: systemd_internal_services
28 # List all systemd internal real services + their state
31 # Check the output of systemctl --list-unit-files systemd-* and parse it into
32 # a hash with the status
36 Facter.add(:systemd) do
37 confine :kernel => :linux
39 Facter.value(:service_provider) == 'systemd'
43 Facter.add(:systemd_version) do
44 confine :systemd => true
46 Facter::Util::Resolution.exec("systemctl --version | awk '/systemd/{ print $2 }'")
50 Facter.add(:systemd_internal_services) do
51 confine :systemd => true
53 command_output = Facter::Util::Resolution.exec(
54 'systemctl list-unit-files --no-legend --no-pager "systemd-*" -t service --state=enabled,disabled,enabled-runtime,indirect'
56 lines = command_output.lines.lazy.map { |line| line.split(/\s+/) }
57 lines.each_with_object({}) do |(service, status, *), result|
58 result[service] = status