Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696223
systemd.rb
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
systemd.rb
View Options
# Fact: systemd
#
# Purpose:
# Determine whether systemd is the init system on the node
#
# Resolution:
# Check if the service_provider fact is systemd
#
# Caveats:
# If you override the service provider then it will return false, even if the
# underlying system still is systemd.
#
# Fact: systemd_version
#
# Purpose:
# Determine the version of systemd installed
#
# Resolution:
# Check the output of systemctl --version
#
# Caveats:
#
# Fact: systemd_internal_services
#
# Purpose:
# List all systemd internal real services + their state
#
# Resolution:
# Check the output of systemctl --list-unit-files systemd-* and parse it into
# a hash with the status
#
# Caveats:
#
Facter
.
add
(
:systemd
)
do
confine
kernel
:
:linux
setcode
do
Facter
.
value
(
:service_provider
)
==
'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
Facter
.
add
(
:systemd_internal_services
)
do
confine
systemd
:
true
setcode
do
command_output
=
Facter
::
Util
::
Resolution
.
exec
(
'systemctl list-unit-files --no-legend --no-pager "systemd-*" -t service --state=enabled,disabled,enabled-runtime,indirect'
)
lines
=
command_output
.
lines
.
lazy
.
map
{
|
line
|
line
.
split
(
%r{\s+}
)
}
lines
.
each_with_object
({})
do
|
(
service
,
status
,
*
),
result
|
result
[
service
]
=
status
end
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 18, 7:26 PM (1 w, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3438382
Attached To
R139 puppet-camptocamp-systemd
Event Timeline
Log In to Comment