Build image before first register run.

This commit is contained in:
Magnus Andersson 2024-02-06 23:13:12 +01:00
parent baa6f6e9d8
commit 457cadcc38
Signed by: mandersson
GPG key ID: 19CB2C58E1F19B16

View file

@ -109,12 +109,21 @@ class podmanrunner::runner (
unless => "test -f /var/lib/systemd/linger/${user}${userpostfix}", unless => "test -f /var/lib/systemd/linger/${user}${userpostfix}",
} }
# If required build runner image by podman-compose
exec { "${user}${userpostfix}-build-runner-image":
command => "${sdrun} /bin/bash -c 'podman-compose build'",
path => '/usr/bin:/usr/sbin:/bin',
provider => shell,
logoutput => false,
unless => "${sdrun} /bin/bash -c 'podman image ls | grep '^localhost/podmanrunner\s\s*3\.[0-9]\.[0-9]''",
}
# If not already done, register runner with forgejo instance. # If not already done, register runner with forgejo instance.
if $userdata and $userdata["token"] and $userdata["url"] { if $userdata and $userdata["token"] and $userdata["url"] {
exec { "${user}${userpostfix}-register-runner": 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 \ 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 \ \"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\"'", --token ${userdata["token"]} --name runner1 --instance ${userdata["url"]} 1>>/data/register.log 2>&1\"'",
path => '/usr/bin:/usr/sbin:/bin', path => '/usr/bin:/usr/sbin:/bin',
provider => shell, provider => shell,
logoutput => false, logoutput => false,