-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(FACT-852) Support for systemd and systemd_version
This commit adds support for systemd and systemd_version facts.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 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 | ||
result = false | ||
init_process_name = Facter::Core::Execution.exec('ps -p 1 -o comm=') | ||
if init_process_name.eql? 'systemd' | ||
result = true | ||
end | ||
end | ||
end | ||
|
||
Facter.add(:systemd_version) do | ||
confine :systemd => true | ||
setcode do | ||
version = Facter::Core::Execution.exec("systemctl --version | grep 'systemd' | awk '{ print $2 }'") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters