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

Enable gpgcheck for YUM RPM based Distributions #205

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ The following parameters are available in the `gitlab_ci_runner` class:
* [`http_proxy`](#-gitlab_ci_runner--http_proxy)
* [`ca_file`](#-gitlab_ci_runner--ca_file)
* [`repo_keysource`](#-gitlab_ci_runner--repo_keysource)
* [`package_keysource`](#-gitlab_ci_runner--package_keysource)
* [`package_gpgcheck`](#-gitlab_ci_runner--package_gpgcheck)

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

Expand Down Expand Up @@ -370,6 +372,22 @@ URL to the gpg file used to sign the apt packages

Default value: `"${repo_base_url}/gpg.key"`

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

Data type: `Optional[Stdlib::HTTPSUrl]`



Default value: `undef`

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

Data type: `Boolean`



Default value: `true`

## Defined types

### <a name="gitlab_ci_runner--runner"></a>`gitlab_ci_runner::runner`
Expand Down
1 change: 1 addition & 0 deletions data/family/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
gitlab_ci_runner::xz_package_name: 'xz'
gitlab_ci_runner::package_keysource: 'https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg'
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
Optional[Stdlib::HTTPUrl] $http_proxy = undef,
Optional[Stdlib::Unixpath] $ca_file = undef,
Stdlib::HTTPSUrl $repo_keysource = "${repo_base_url}/gpg.key",
Optional[Stdlib::HTTPSUrl] $package_keysource = undef,
Boolean $package_gpgcheck = true,
) {
if $manage_docker {
# workaround for cirunner issue #1617
Expand Down
19 changes: 11 additions & 8 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# @api private
#
class gitlab_ci_runner::repo (
$repo_base_url = $gitlab_ci_runner::repo_base_url,
$repo_keyserver = $gitlab_ci_runner::repo_keyserver,
$repo_keysource = $gitlab_ci_runner::repo_keysource,
$package_name = $gitlab_ci_runner::package_name,
$repo_base_url = $gitlab_ci_runner::repo_base_url,
$repo_keyserver = $gitlab_ci_runner::repo_keyserver,
$repo_keysource = $gitlab_ci_runner::repo_keysource,
$package_keysource = $gitlab_ci_runner::package_keysource,
$package_gpgcheck = $gitlab_ci_runner::package_gpgcheck,
$package_name = $gitlab_ci_runner::package_name,
) {
assert_private()
case $facts['os']['family'] {
Expand Down Expand Up @@ -42,13 +44,14 @@
$source_base_url = "${repo_base_url}/runner/${package_name}/el/\$releasever/SRPMS"
}

$_gpgkeys = [$repo_keysource,$package_keysource].delete_undef_values.join(' ')
Copy link
Member

Choose a reason for hiding this comment

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

oh I didn't know that a repo config allows multiple keys

yumrepo { "runner_${package_name}":
ensure => 'present',
baseurl => $base_url,
descr => "runner_${package_name}",
enabled => '1',
gpgcheck => '0',
gpgkey => $repo_keysource,
gpgcheck => String(Integer($package_gpgcheck)),
gpgkey => $_gpgkeys,
repo_gpgcheck => '1',
sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
sslverify => '1',
Expand All @@ -59,8 +62,8 @@
baseurl => $source_base_url,
descr => "runner_${package_name}-source",
enabled => '1',
gpgcheck => '0',
gpgkey => $repo_keysource,
gpgcheck => String(Integer($package_gpgcheck)),
gpgkey => $_gpgkeys,
repo_gpgcheck => '1',
sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
sslverify => '1',
Expand Down
22 changes: 18 additions & 4 deletions spec/classes/gitlab_ci_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@
baseurl: "https://packages.gitlab.com/runner/gitlab-runner/el/#{os_release_version}/$basearch",
descr: 'runner_gitlab-runner',
enabled: '1',
gpgcheck: '0',
gpgkey: 'https://packages.gitlab.com/gpg.key',
gpgcheck: '1',
gpgkey: 'https://packages.gitlab.com/gpg.key https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg',
repo_gpgcheck: '1',
sslcacert: '/etc/pki/tls/certs/ca-bundle.crt',
sslverify: '1'
Expand All @@ -421,13 +421,27 @@
baseurl: "https://packages.gitlab.com/runner/gitlab-runner/el/#{os_release_version}/SRPMS",
descr: 'runner_gitlab-runner-source',
enabled: '1',
gpgcheck: '0',
gpgkey: 'https://packages.gitlab.com/gpg.key',
gpgcheck: '1',
gpgkey: 'https://packages.gitlab.com/gpg.key https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-49F16C5CC3A0F81F.pub.gpg',
repo_gpgcheck: '1',
sslcacert: '/etc/pki/tls/certs/ca-bundle.crt',
sslverify: '1'
)
end

context 'when package_gpgcheck is false' do
let(:params) do
super().merge(package_gpgcheck: false)
end

it do
is_expected.to contain_yumrepo('runner_gitlab-runner').with_gpgcheck('0')
end

it do
is_expected.to contain_yumrepo('runner_gitlab-runner-source').with_gpgcheck('0')
end
end
end
end

Expand Down