Commit c133d65c authored by James T. Lee's avatar James T. Lee
Browse files

New defined type for GitLab Runner service

Add a new defined type at `nest::service::gitlab_runner`.  It has a
minimal set of parameters to get it up and running.  More can be added.

Use the new defined type to build a set of runners on falcon.
parent a4724adf
...@@ -6,6 +6,7 @@ class nest ( ...@@ -6,6 +6,7 @@ class nest (
$root_mail_alias, $root_mail_alias,
$ssh_private_key, $ssh_private_key,
$pw_hash, $pw_hash,
String $gitlab_runner_token,
$cnames = {}, $cnames = {},
$distcc_hosts = {}, $distcc_hosts = {},
......
...@@ -243,13 +243,19 @@ class nest::node::falcon { ...@@ -243,13 +243,19 @@ class nest::node::falcon {
target => '/etc/sysctl.d/nest.conf', target => '/etc/sysctl.d/nest.conf',
} }
nest::lib::package_use { 'media-sound/beets': nest::service::gitlab_runner {
use => ['ffmpeg', 'gstreamer', 'lastfm', 'replaygain'], default:
} host => 'gitlab.james.tl',
registration_token => $::nest::gitlab_runner_token,
;
# Temporarily remove beets because it is being dropped from gentoo 'gitlab.james.tl':
# Will reinstall after bringing the ebuild into my repo and enable Python 3.7 support # use defaults
package { 'media-sound/beets': ;
ensure => absent,
'gitlab.james.tl-docker':
docker_volumes => ['/var/run/docker.sock:/var/run/docker.sock'],
tag_list => ['docker'],
;
} }
} }
define nest::service::gitlab_runner (
String $registration_token,
String $host = $name,
String $default_image = 'ubuntu:latest',
String $description = $facts['fqdn'],
Array[String] $docker_volumes = [],
Array[String] $tag_list = [],
) {
include 'nest::service::docker'
unless defined(Nest::Lib::Srv['gitlab-runner']) {
nest::lib::srv { 'gitlab-runner': }
}
file { "/srv/gitlab-runner/${name}":
ensure => directory,
mode => '0755',
owner => 'root',
group => 'root',
require => Nest::Lib::Srv['gitlab-runner'],
}
$description_real = $description ? {
undef => $facts['fqdn'],
default => "${facts['fqdn']}-${description}",
}
$docker_volume_args = $docker_volumes.map |$volume| {
['--docker-volumes', $volume]
}.flatten
# See: https://docs.gitlab.com/runner/register/index.html#one-line-registration-command
$register_command = [
'/usr/bin/docker', 'run', '--rm',
'-v', "/srv/gitlab-runner/${name}:/etc/gitlab-runner",
'gitlab/gitlab-runner', 'register',
'--non-interactive',
'--executor', 'docker',
'--docker-image', $default_image,
'--url', "https://${host}/",
'--registration-token', $registration_token,
'--description', $description,
'--tag-list', $tag_list.join(','),
] + $docker_volume_args
exec { "gitlab-runner-${name}-register":
command => shellquote($register_command),
creates => "/srv/gitlab-runner/${name}/config.toml",
require => File["/srv/gitlab-runner/${name}"],
}
docker::run { "gitlab-runner-${name}":
image => 'gitlab/gitlab-runner',
volumes => [
'/var/run/docker.sock:/var/run/docker.sock',
"/srv/gitlab-runner/${name}:/etc/gitlab-runner",
],
service_provider => 'systemd',
require => Exec["gitlab-runner-${name}-register"],
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment