2024-01-18 06:52:38 +00:00
|
|
|
# Class for forgeo action runner.
|
2024-01-18 08:19:55 +00:00
|
|
|
class podmanrunner::runner (
|
|
|
|
Integer $replicas = 2,
|
|
|
|
)
|
2024-01-18 06:52:38 +00:00
|
|
|
{
|
2024-01-19 08:33:10 +00:00
|
|
|
$username='runneruser'
|
2024-01-18 14:39:26 +00:00
|
|
|
package { 'podman':
|
|
|
|
ensure => installed,
|
|
|
|
provider => apt,
|
|
|
|
}
|
2024-01-18 21:25:44 +00:00
|
|
|
|
|
|
|
package { 'systemd-container':
|
|
|
|
ensure => installed,
|
|
|
|
provider => apt,
|
|
|
|
}
|
|
|
|
|
2024-01-19 08:33:10 +00:00
|
|
|
range(1,$replicas).each |$x| {
|
2024-01-18 21:25:44 +00:00
|
|
|
|
2024-01-19 08:33:10 +00:00
|
|
|
user { "${username}${x}":
|
|
|
|
ensure => present,
|
|
|
|
home => "/opt/${username}${x}",
|
|
|
|
shell => '/usr/sbin/nologin',
|
|
|
|
uid => "${ $x + 1001}",
|
|
|
|
managehome => true,
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "/opt/${username}${x}/docker-compose.yaml":
|
|
|
|
ensure => file,
|
|
|
|
content => template('podmanrunner/docker-compose.yaml.erb'),
|
|
|
|
owner => "${username}${x}",
|
|
|
|
group => "${username}${x}",
|
2024-01-23 21:03:05 +00:00
|
|
|
mode => '0400',
|
2024-01-19 08:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
file { "/opt/${username}${x}/bin":
|
|
|
|
ensure => directory,
|
|
|
|
mode => '0700',
|
|
|
|
owner => "${username}${x}",
|
|
|
|
group => "${username}${x}",
|
|
|
|
}
|
2024-01-18 21:25:44 +00:00
|
|
|
|
2024-01-19 08:33:10 +00:00
|
|
|
file { "/opt/${username}${x}/bin/podman-compose":
|
|
|
|
ensure => file,
|
2024-01-23 21:03:05 +00:00
|
|
|
mode => '0500',
|
2024-01-19 08:33:10 +00:00
|
|
|
source => 'puppet:///modules/podmanrunner/podman-compose',
|
|
|
|
owner => "${username}${x}",
|
|
|
|
group => "${username}${x}",
|
|
|
|
}
|
2024-01-23 21:03:05 +00:00
|
|
|
|
|
|
|
file { "/opt/${username}${x}/runnerimage":
|
|
|
|
ensure => directory,
|
|
|
|
mode => '0700',
|
|
|
|
owner => "${username}${x}",
|
|
|
|
group => "${username}${x}",
|
|
|
|
}
|
|
|
|
|
|
|
|
file { "/opt/${username}${x}/runnerimage/Containerfile":
|
|
|
|
ensure => file,
|
|
|
|
content => template('podmanrunner/runnerimage-Containerfile.erb'),
|
|
|
|
owner => "${username}${x}",
|
|
|
|
group => "${username}${x}",
|
|
|
|
mode => '0400',
|
|
|
|
}
|
|
|
|
|
2024-01-19 09:50:39 +00:00
|
|
|
exec { "enable-${username}${x}-linger":
|
|
|
|
command => "loginctl enable-linger ${username}${x}",
|
|
|
|
path => '/usr/bin:/usr/sbin:/bin',
|
|
|
|
provider => shell,
|
|
|
|
logoutput => false,
|
|
|
|
unless => "test -f /var/lib/systemd/linger/${username}${x}",
|
|
|
|
}
|
2024-01-18 15:27:32 +00:00
|
|
|
}
|
2024-01-18 06:52:38 +00:00
|
|
|
}
|