Improve formating of manifest
This commit is contained in:
parent
23679447b2
commit
baa6f6e9d8
|
@ -30,7 +30,8 @@ class podmanrunner::runner (
|
|||
|
||||
$runnerdata.each |$user,$userdata| {
|
||||
|
||||
user { "${user}${userpostfix}":
|
||||
$sdrun = "systemd-run --wait --user --machine=${user}${userpostfix}@"
|
||||
user { "${user}${userpostfix}":
|
||||
ensure => present,
|
||||
home => "/opt/${user}${userpostfix}",
|
||||
shell => '/usr/sbin/nologin',
|
||||
|
@ -82,20 +83,22 @@ class podmanrunner::runner (
|
|||
|
||||
# Make sure the podman user can read the /data dir
|
||||
exec { "make-${user}${userpostfix}-own-runnerdata":
|
||||
command => "systemd-run --wait --user --machine=${user}${userpostfix}@ /bin/bash -c 'podman unshare chown 1000:1000 /opt/${user}${userpostfix}/runnerdata'",
|
||||
command => "${sdrun} /bin/bash -c 'podman unshare chown 1000:1000 /opt/${user}${userpostfix}/runnerdata'",
|
||||
path => '/usr/bin:/usr/sbin:/bin',
|
||||
provider => shell,
|
||||
logoutput => false,
|
||||
unless => "systemd-run --wait --user --machine=${user}${userpostfix}@ /bin/bash -c 'podman unshare stat --format %u /opt/${user}${userpostfix}/runnerdata | grep ^1000$ && podman unshare stat --format %g /opt/${user}${userpostfix}/runnerdata | grep ^1000$'",
|
||||
unless => "${sdrun} /bin/bash -c 'podman unshare stat --format %u /opt/${user}${userpostfix}/runnerdata | \
|
||||
grep ^1000$ && podman unshare stat --format %g /opt/${user}${userpostfix}/runnerdata | grep ^1000$'",
|
||||
}
|
||||
|
||||
# Make sure the podman user can read the /data/config.yml file
|
||||
exec { "podman-${user}${userpostfix}-own-runner-config":
|
||||
command => "systemd-run --wait --user --machine=${user}${userpostfix}@ /bin/bash -c 'podman unshare chown 1000:1000 /opt/${user}${userpostfix}/runnerdata/config.yml'",
|
||||
command => "${sdrun} /bin/bash -c 'podman unshare chown 1000:1000 /opt/${user}${userpostfix}/runnerdata/config.yml'",
|
||||
path => '/usr/bin:/usr/sbin:/bin',
|
||||
provider => shell,
|
||||
logoutput => false,
|
||||
unless => "systemd-run --wait --user --machine=${user}${userpostfix}@ /bin/bash -c 'podman unshare stat --format %u /opt/${user}${userpostfix}/runnerdata/config.yml | grep ^1000$ && podman unshare stat --format %g /opt/${user}${userpostfix}/runnerdata/config.yml | grep ^1000$'",
|
||||
unless => "${sdrun} /bin/bash -c 'podman unshare stat --format %u /opt/${user}${userpostfix}/runnerdata/config.yml | \
|
||||
grep ^1000$ && podman unshare stat --format %g /opt/${user}${userpostfix}/runnerdata/config.yml | grep ^1000$'",
|
||||
}
|
||||
|
||||
exec { "enable-${user}${userpostfix}-linger":
|
||||
|
@ -105,5 +108,18 @@ class podmanrunner::runner (
|
|||
logoutput => false,
|
||||
unless => "test -f /var/lib/systemd/linger/${user}${userpostfix}",
|
||||
}
|
||||
|
||||
# If not already done, register runner with forgejo instance.
|
||||
if $userdata and $userdata["token"] and $userdata["url"] {
|
||||
exec { "${user}${userpostfix}-register-runner":
|
||||
command => "${sdrun} /bin/bash -c 'podman run -it --rm -u podman -v ./runnerdata:/data:Z localhost/podmanrunner:3.3.0 /bin/bash -c \
|
||||
\"date >> /data/register.log && forgejo-runner --config /data/config.yml register --no-interactive \
|
||||
--token ${userdata[\"token\"]} --name runner1 --instance ${userdata[\"url\"]} 1>>/data/register.log 2>&1\"'",
|
||||
path => '/usr/bin:/usr/sbin:/bin',
|
||||
provider => shell,
|
||||
logoutput => false,
|
||||
unless => "test -f /opt/${user}${userpostfix}/runnerdata/.runner",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue