Puppet Function: systemd::systemd_escape
- Defined in:
-
lib/puppet/functions/systemd/systemd_escape.rb
- Function type:
- Ruby 4.x API
Summary
Escape strings by call the `systemd-escape` command in the background.
Overview
systemd::systemd_escape(String $input, Optional[Optional[Boolean]] $path) ⇒ String
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/puppet/functions/systemd/systemd_escape.rb', line 4
Puppet::Functions.create_function(:'systemd::systemd_escape') do
dispatch :escape do
param 'String', :input
optional_param 'Optional[Boolean]', :path
return_type 'String'
end
def escape(input, path = false)
args = []
args.push('--path') if path
args.push(input)
exec_systemd(args)
end
def exec_systemd(*args)
exec_args = { failonfail: true, combine: false }
escaped = Puppet::Util::Execution.execute(['systemd-escape', args], **exec_args)
escaped.strip
end
end
|