10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# 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, some selinux, possibly polkit blocking access
# https://github.com/voxpupuli/puppet-systemd/issues/459
# https://github.com/voxpupuli/puppet-systemd/issues/664
$_cmd_array = [
'runuser', '-u', $user, '--' ,'/usr/bin/bash', '-c',
"env XDG_RUNTIME_DIR=/run/user/\$(id -u) /usr/bin/systemctl --user ${arguments.join(' ')}",
]
return $_cmd_array
}
|