Skip to content

Commit 783f6b7

Browse files
committed
Merge pull request #6 from roidelapluie/facts
Add systemd facts
2 parents 6d47fd4 + b19ae68 commit 783f6b7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lib/facter/systemd.rb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Fact: systemd
2+
#
3+
# Purpose:
4+
# Determine whether SystemD is the init system on the node
5+
#
6+
# Resolution:
7+
# Check the name of the process 1 (ps -p 1)
8+
#
9+
# Caveats:
10+
#
11+
12+
# Fact: systemd-version
13+
#
14+
# Purpose:
15+
# Determine the version of systemd installed
16+
#
17+
# Resolution:
18+
# Check the output of systemctl --version
19+
#
20+
# Caveats:
21+
#
22+
23+
Facter.add(:systemd) do
24+
confine :kernel => :linux
25+
setcode do
26+
Facter::Core::Execution.exec('ps -p 1 -o comm=') == 'systemd'
27+
end
28+
end
29+
30+
Facter.add(:systemd_version) do
31+
confine :systemd => true
32+
setcode do
33+
Facter::Core::Execution.exec("systemctl --version | grep 'systemd' | awk '{ print $2 }'")
34+
end
35+
end

0 commit comments

Comments
 (0)