podmanrunner/manifests/runner.pp

58 lines
1.4 KiB
ObjectPascal
Raw Normal View History

# Class for forgeo action runner.
class podmanrunner::runner (
Integer $replicas = 2,
)
{
$username='runneruser'
package { 'podman':
ensure => installed,
provider => apt,
}
package { 'systemd-container':
ensure => installed,
provider => apt,
}
range(1,$replicas).each |$x| {
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}",
mode => '0600',
}
file { "/opt/${username}${x}/bin":
ensure => directory,
mode => '0700',
owner => "${username}${x}",
group => "${username}${x}",
}
file { "/opt/${username}${x}/bin/podman-compose":
ensure => file,
mode => '500',
source => 'puppet:///modules/podmanrunner/podman-compose',
owner => "${username}${x}",
group => "${username}${x}",
}
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
}
}