summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Pinson <github+aem1eeshi1@raphink.net>2016-05-04 09:28:37 +0200
committerRaphaël Pinson <github+aem1eeshi1@raphink.net>2016-05-04 09:28:37 +0200
commit783f6b7a13f21c78d89241b2e5cebe82d80febfb (patch)
treefda523af240fe620effb4d824a4a46fb77ea11a5
parent6d47fd4999fe03eba6fb11c4490dcbb90d937900 (diff)
parentb19ae68789e2a7abe0368d710f5860eef2a70a1d (diff)
Merge pull request #6 from roidelapluie/facts
Add systemd facts
-rw-r--r--lib/facter/systemd.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/facter/systemd.rb b/lib/facter/systemd.rb
new file mode 100644
index 0000000..b4b11fb
--- /dev/null
+++ b/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::Core::Execution.exec('ps -p 1 -o comm=') == 'systemd'
+ end
+end
+
+Facter.add(:systemd_version) do
+ confine :systemd => true
+ setcode do
+ Facter::Core::Execution.exec("systemctl --version | grep 'systemd' | awk '{ print $2 }'")
+ end
+end