Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic SuSE support #194

Merged
merged 8 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
24 changes: 19 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,17 @@ gitlab_ci_runner::runners:
ensure: absent
```

## SLES

There are no gitlab_ci_runner repositories for SLES/zypper available!
Please set the following data to be able to use this module on SLES:

```yaml
gitlab_ci_runner::install_method: 'binary' # required for SLES
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Stdlib::HTTPUrl $binary_source = 'https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-amd64',
Stdlib::HTTPSUrl $binary_source = 'https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-amd64',

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about people with local http server without https? The idea is to let people override the url.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to support plaintext HTTP in 2024? :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Customer insists on using an internal HTTP only server. :-(

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' {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it Suse for suse opensoure and enterprise? does the code work on both systems?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both. Or even better: this method works for any OS! I am about to implement the any OS usage in a next PR

exec { "${gitlab_ci_runner::binary_path} install -u ${gitlab_ci_runner::user}":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to notify the exec when there's an update for the runner? Do we need to run systemctl daemon-reload before the service resource?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. My test installation did not require a separate systemctl daemon-reload

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 @@ -82,6 +82,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
Loading