Skip to content

Commit

Permalink
Merge pull request #205 from traylenator/gpgkey
Browse files Browse the repository at this point in the history
Enable gpgcheck for YUM  RPM based Distributions
  • Loading branch information
bastelfreak authored Nov 22, 2024
2 parents d9043e6 + abb44c5 commit 360f3c9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
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(' ')
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

0 comments on commit 360f3c9

Please sign in to comment.