summaryrefslogtreecommitdiff
path: root/puppet/modules/systemd/lib/facter
diff options
context:
space:
mode:
authorVarac <varac@leap.se>2017-01-18 17:40:25 +0000
committerVarac <varac@leap.se>2017-01-18 17:40:25 +0000
commit8cba23d7308af4ed018d42935adee442e2e53134 (patch)
tree96135e4aed98a2e366d5ba1c05b37e2cdeebf901 /puppet/modules/systemd/lib/facter
parentdd189d2de941ec081261ced814a9c822e5ef02a1 (diff)
parent80e0ca380e92fe435622dbd35d1a5baedb6c3f92 (diff)
Merge branch 'apache-auto-restart' into 'master'
Add apache auto-restart extension file See merge request !66
Diffstat (limited to 'puppet/modules/systemd/lib/facter')
-rw-r--r--puppet/modules/systemd/lib/facter/systemd.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/puppet/modules/systemd/lib/facter/systemd.rb b/puppet/modules/systemd/lib/facter/systemd.rb
new file mode 100644
index 00000000..4361f775
--- /dev/null
+++ b/puppet/modules/systemd/lib/facter/systemd.rb
@@ -0,0 +1,35 @@
+# Fact: systemd
+#
+# Purpose:
+# Determine whether SystemD is the init system on the node
+#
+# Resolution:
+# Check the name of the process 1 (ps -p 1)
+#
+# Caveats:
+#
+
+# Fact: systemd-version
+#
+# Purpose:
+# Determine the version of systemd installed
+#
+# Resolution:
+# Check the output of systemctl --version
+#
+# Caveats:
+#
+
+Facter.add(:systemd) do
+ confine :kernel => :linux
+ setcode do
+ Facter::Util::Resolution.exec('ps -p 1 -o comm=') == 'systemd'
+ end
+end
+
+Facter.add(:systemd_version) do
+ confine :systemd => true
+ setcode do
+ Facter::Util::Resolution.exec("systemctl --version | awk '/systemd/{ print $2 }'")
+ end
+end