Skip to content

Commit

Permalink
Merge pull request #194 from tuxmea/sles
Browse files Browse the repository at this point in the history
Add basic SuSE support
  • Loading branch information
tuxmea authored Jun 17, 2024
2 parents 71569e9 + f3e99dc commit 26cf666
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 22 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ fixtures:
ruby_task_helper: "https://github.com/puppetlabs/puppetlabs-ruby_task_helper.git"
translate: "https://github.com/puppetlabs/puppetlabs-translate.git"
yumrepo_core: "https://github.com/puppetlabs/puppetlabs-yumrepo_core.git"
archive: "https://github.com/voxpupuli/puppet-archive.git"
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@

#### Table of Contents

1. [Overview](#overview)
1. [Usage - Configuration options and additional functionality](#usage)
1. [Limitations - OS compatibility, etc.](#limitations)
1. [Upgrading from version 3](#upgrading-from-version-3)
1. [License](#license)
- [Gitlab-CI runner module for Puppet](#gitlab-ci-runner-module-for-puppet)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [Usage](#usage)
- [SLES](#sles)
- [Upgrading from version 3](#upgrading-from-version-3)
- [Limitations](#limitations)
- [License](#license)

## Overview

Expand Down Expand Up @@ -69,6 +72,20 @@ gitlab_ci_runner::runners:
ensure: absent
```

## SLES

There are no gitlab_ci_runner repositories for SLES/zypper available!
Instead one can use the go binary.
This setup requires the [puppet-archive](https://github.com/voxpupuli/puppet-archive) module.

Please set the following data to be able to use this module on SLES:

```yaml
gitlab_ci_runner::install_method: 'binary' # required for SLES
gitlab_ci_runner::binary_source: 'https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-amd64' # default value
gitlab_ci_runner::binary_path: '/usr/local/bin/gitlab-runner' # default value
```

## Upgrading from version 3

Version 4 of this module introduces some big changes.
Expand Down
54 changes: 54 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ The following parameters are available in the `gitlab_ci_runner` class:
* [`listen_address`](#-gitlab_ci_runner--listen_address)
* [`session_server`](#-gitlab_ci_runner--session_server)
* [`manage_docker`](#-gitlab_ci_runner--manage_docker)
* [`install_method`](#-gitlab_ci_runner--install_method)
* [`binary_source`](#-gitlab_ci_runner--binary_source)
* [`binary_path`](#-gitlab_ci_runner--binary_path)
* [`manage_user`](#-gitlab_ci_runner--manage_user)
* [`user`](#-gitlab_ci_runner--user)
* [`group`](#-gitlab_ci_runner--group)
* [`manage_repo`](#-gitlab_ci_runner--manage_repo)
* [`package_ensure`](#-gitlab_ci_runner--package_ensure)
* [`package_name`](#-gitlab_ci_runner--package_name)
Expand Down Expand Up @@ -190,6 +196,54 @@ If docker should be installs (uses the puppetlabs-docker).

Default value: `false`

##### <a name="-gitlab_ci_runner--install_method"></a>`install_method`

Data type: `Enum['repo', 'binary']`

If repo or binary should be installed

Default value: `'repo'`

##### <a name="-gitlab_ci_runner--binary_source"></a>`binary_source`

Data type: `Stdlib::HTTPUrl`

URL to the binary file

Default value: `'https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-amd64'`

##### <a name="-gitlab_ci_runner--binary_path"></a>`binary_path`

Data type: `Stdlib::Absolutepath`

Absolute path where to install gitlab_runner binary

Default value: `'/usr/local/bin/gitlab-runner'`

##### <a name="-gitlab_ci_runner--manage_user"></a>`manage_user`

Data type: `Boolean`

If the user should be managed.

Default value: `false`

##### <a name="-gitlab_ci_runner--user"></a>`user`

Data type: `String[1]`

The user to manage.

Default value: `'gitlab-runner'`

##### <a name="-gitlab_ci_runner--group"></a>`group`

Data type: `String[1]`

The group to manage.

Default value: `$user`

##### <a name="-gitlab_ci_runner--manage_repo"></a>`manage_repo`

Data type: `Boolean`
Expand Down
5 changes: 5 additions & 0 deletions data/family/Suse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
gitlab_ci_runner::install_method: 'binary'
gitlab_ci_runner::manage_repo: false
gitlab_ci_runner::manage_config_dir: true
gitlab_ci_runner::manage_user: true
18 changes: 18 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
# Session server lets users interact with jobs, for example, in the interactive web terminal.
# @param manage_docker
# If docker should be installs (uses the puppetlabs-docker).
# @param install_method
# If repo or binary should be installed
# @param binary_source
# URL to the binary file
# @param binary_path
# Absolute path where to install gitlab_runner binary
# @param manage_user
# If the user should be managed.
# @param user
# The user to manage.
# @param group
# The group to manage.
# @param manage_repo
# If the repository should be managed.
# @param package_ensure
Expand Down Expand Up @@ -89,6 +101,12 @@
Optional[String] $sentry_dsn = undef,
Optional[Pattern[/.*:.+/]] $listen_address = undef,
Optional[Gitlab_ci_runner::Session_server] $session_server = undef,
Enum['repo', 'binary'] $install_method = 'repo',
Stdlib::HTTPUrl $binary_source = 'https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-amd64',
Stdlib::Absolutepath $binary_path = '/usr/local/bin/gitlab-runner',
Boolean $manage_user = false,
String[1] $user = 'gitlab-runner',
String[1] $group = $user,
Boolean $manage_docker = false,
Boolean $manage_repo = true,
String $package_ensure = installed,
Expand Down
36 changes: 34 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,39 @@
) {
assert_private()

package { $package_name:
ensure => $package_ensure,
case $gitlab_ci_runner::install_method {
'repo': {
package { $package_name:
ensure => $package_ensure,
}
}
'binary': {
$_package_ensure = $package_ensure ? {
'installed' => 'present',
default => $package_ensure,
}
archive { $gitlab_ci_runner::binary_path:
ensure => $_package_ensure,
source => $gitlab_ci_runner::binary_source,
extract => false,
creates => $gitlab_ci_runner::binary_path,
}
file { $gitlab_ci_runner::binary_path:
ensure => file,
mode => '0755',
}
if $gitlab_ci_runner::manage_user {
group { $gitlab_ci_runner::group:
ensure => present,
}
user { $gitlab_ci_runner::user:
ensure => present,
gid => $gitlab_ci_runner::group,
}
}
}
default: {
fail("Unsupported install method: ${gitlab_ci_runner::install_method}")
}
}
}
5 changes: 5 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
) {
assert_private()

if $facts['os']['family'] == 'Suse' {
exec { "${gitlab_ci_runner::binary_path} install -u ${gitlab_ci_runner::user}":
creates => '/etc/systemd/system/gitlab-runner.service',
}
}
service { $package_name:
ensure => running,
enable => true,
Expand Down
7 changes: 7 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
"20.04",
"22.04"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"12",
"15"
]
}
],
"requirements": [
Expand Down
35 changes: 20 additions & 15 deletions spec/classes/gitlab_ci_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@

it { is_expected.not_to contain_class('docker') }
it { is_expected.not_to contain_class('docker::images') }
it { is_expected.to contain_package('gitlab-runner') }

it { is_expected.to contain_package('gitlab-runner') } unless facts[:os]['family'] == 'Suse'

it { is_expected.to contain_service('gitlab-runner') }
it { is_expected.to contain_class('gitlab_ci_runner::install') }

Expand Down Expand Up @@ -337,20 +339,22 @@
}
end

it { is_expected.to compile }
unless facts[:os]['family'] == 'Suse'
it { is_expected.to compile }

it { is_expected.to contain_class('docker') }
it { is_expected.to contain_class('docker') }

it do
is_expected.to contain_class('docker::images').
with(
images: {
'ubuntu_focal' => {
'image' => 'ubuntu',
'image_tag' => 'focal'
it do
is_expected.to contain_class('docker::images').
with(
images: {
'ubuntu_focal' => {
'image' => 'ubuntu',
'image_tag' => 'focal'
}
}
}
)
)
end
end
end

Expand All @@ -361,9 +365,10 @@
)
end

it { is_expected.to compile }
it { is_expected.to contain_class('gitlab_ci_runner::repo') }

unless facts[:os]['family'] == 'Suse'
it { is_expected.to compile }
it { is_expected.to contain_class('gitlab_ci_runner::repo') }
end
case facts[:os]['family']
when 'Debian'
it do
Expand Down

0 comments on commit 26cf666

Please sign in to comment.