feat: add gitea runner role
- ensure docker is configured - create runner user/group - deploy config.yaml from hiera hash - install runner from url - register the runner with the gitea instance - manage the act_runner service
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# profiles::gitea::init
|
||||
class profiles::gitea::runner (
|
||||
String $registration_token,
|
||||
Stdlib::HTTPSUrl $source,
|
||||
String $user = 'runner',
|
||||
String $group = 'runner',
|
||||
Stdlib::Absolutepath $home = '/data/runner',
|
||||
Hash $config = {},
|
||||
Stdlib::HTTPSUrl $instance = 'https://git.query.consul',
|
||||
String $version = '0.2.10',
|
||||
) {
|
||||
|
||||
group { $group:
|
||||
ensure => 'present',
|
||||
}
|
||||
|
||||
user { $user:
|
||||
ensure => 'present',
|
||||
home => $home,
|
||||
managehome => true,
|
||||
forcelocal => true,
|
||||
groups => ['docker'],
|
||||
gid => $group,
|
||||
require => Group[$group],
|
||||
}
|
||||
|
||||
file { "${home}/config.yaml":
|
||||
ensure => file,
|
||||
content => to_yaml($config),
|
||||
owner => $user,
|
||||
group => $group,
|
||||
require => User[$user],
|
||||
}
|
||||
|
||||
archive { '/usr/local/bin/act_runner':
|
||||
ensure => present,
|
||||
extract => false,
|
||||
source => $source,
|
||||
creates => '/usr/local/bin/act_runner',
|
||||
cleanup => true,
|
||||
}
|
||||
|
||||
file { '/usr/local/bin/act_runner':
|
||||
ensure => 'file',
|
||||
mode => '0755',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
require => Archive['/usr/local/bin/act_runner'],
|
||||
}
|
||||
|
||||
exec {'register_act_runner':
|
||||
command => "/usr/local/bin/act_runner register \
|
||||
--no-interactive \
|
||||
--instance ${instance} \
|
||||
--token ${registration_token} \
|
||||
--name ${facts['networking']['hostname']} \
|
||||
--config ${home}/config.yaml",
|
||||
creates => "${home}/.runner",
|
||||
cwd => $home,
|
||||
user => $user,
|
||||
group => $group,
|
||||
require => [
|
||||
File['/usr/local/bin/act_runner'],
|
||||
File["${home}/config.yaml"],
|
||||
],
|
||||
}
|
||||
|
||||
systemd::unit_file {'act_runner.service':
|
||||
enable => true,
|
||||
active => true,
|
||||
content => template('profiles/gitea/act_runner.service.erb'),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Gitea Actions runner
|
||||
Documentation=https://gitea.com/gitea/act_runner
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/act_runner daemon --config <%= @home %>/config.yaml
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
WorkingDirectory=<%= @home %>
|
||||
TimeoutSec=0
|
||||
RestartSec=10
|
||||
Restart=always
|
||||
User=<%= @user %>
|
||||
Group=<%= @group %>
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,11 @@
|
||||
# a role to deploy the gitea runner
|
||||
class roles::infra::git::runner {
|
||||
if $facts['firstrun'] {
|
||||
include profiles::defaults
|
||||
include profiles::firstrun::init
|
||||
}else{
|
||||
include profiles::defaults
|
||||
include profiles::base
|
||||
include profiles::base::datavol
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user