- 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
74 lines
1.8 KiB
Puppet
74 lines
1.8 KiB
Puppet
# 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'),
|
|
}
|
|
}
|