10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'functions/systemctl_user.pp', line 10
function systemd::systemctl_user(String[1] $user, Array[String[1],1] $arguments) >> Array {
# Why is runuser being used here for older systemds?
# More obvious command arrays to return would be:
# * ['run0','--user',$user,'systemctl','--user'] + $arguments
# * ['systemctl', '--user', '--machine', "${user}@.host"] + $arguments
# * ['systemd-run','--wait','--pipe', 'systemctl', '--user', '--machine', "${user}@.host"] + $arguments
# However none of these work when puppet is run as a background service. They only work with
# puppet apply in the foreground. Reason is unclear, possibly polkit blocking access
# https://github.com/voxpupuli/puppet-systemd/issues/459
$_cmd_array = Integer($facts['systemd_version']) < 256 ? {
true => [
'runuser', '-u', $user, '--' ,'/usr/bin/bash', '-c',
"env XDG_RUNTIME_DIR=/run/user/\$(id -u) /usr/bin/systemctl --user ${arguments.join(' ')}",
],
default => ['run0','--user',$user,'/usr/bin/systemctl','--user'] + $arguments,
}
return $_cmd_array
}
|