Skip to content

Commit 9e717f3

Browse files
committed
Add parameters to apt::source to avoid requiring an internet connexion
Signed-off-by: Cedric Couralet <[email protected]>
1 parent 0868ca0 commit 9e717f3

File tree

4 files changed

+100
-22
lines changed

4 files changed

+100
-22
lines changed

REFERENCE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,33 @@ Data type: `Optional[Stdlib::Fqdn]`
167167

168168
The keyserver which should be used to get the repository key.
169169

170+
Default value: `undef`
171+
172+
##### `repo_keycontent`
173+
174+
Data type: `Optional[String]`
175+
176+
The key content to use, useful when internet connexion is not available.
177+
178+
Default value: `undef`
179+
180+
##### `repo_keysource`
181+
182+
Data type: `Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]`
183+
184+
The key source to use, useful when internet connexion is not available and you want to use
185+
an internal source.
186+
187+
Default value: `undef`
188+
189+
##### `repo_keyweak_ssl`
190+
191+
Data type: `Boolean`
192+
193+
Specifies whether strict SSL verification on a https URL should be disabled when fetching the key.
194+
Valid options: true or false.
195+
196+
170197
Default value: `undef`
171198

172199
##### `config_path`

manifests/init.pp

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,37 @@
4343
# The base repository url.
4444
# @param repo_keyserver
4545
# The keyserver which should be used to get the repository key.
46+
# @param repo_keycontent
47+
# Supplies the entire GPG key. Useful in case the key can't be fetched from a remote location and using a file resource is inconvenient.
48+
# @param repo_keysource
49+
# Specifies the location of an existing GPG key file to copy. Valid options: a string containing a URL (ftp://, http://, or https://) or
50+
# an absolute path.
51+
# @param repo_keyweak_ssl
52+
# Specifies whether strict SSL verification on a https URL should be disabled. Valid options: true or false.
4653
# @param config_path
4754
# The path to the config file of Gitlab runner.
4855
#
4956
class gitlab_ci_runner (
50-
String $xz_package_name, # Defaults in module hieradata
51-
Hash $runners = {},
52-
Hash $runner_defaults = {},
53-
Optional[Integer] $concurrent = undef,
54-
Optional[Integer] $check_interval = undef,
55-
Optional[String] $builds_dir = undef,
56-
Optional[String] $cache_dir = undef,
57-
Optional[Pattern[/.*:.+/]] $metrics_server = undef,
58-
Optional[Pattern[/.*:.+/]] $listen_address = undef,
59-
Optional[String] $sentry_dsn = undef,
60-
Boolean $manage_docker = false,
61-
Boolean $manage_repo = true,
62-
String $package_ensure = installed,
63-
String $package_name = 'gitlab-runner',
64-
Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com',
65-
Optional[Stdlib::Fqdn] $repo_keyserver = undef,
66-
String $config_path = '/etc/gitlab-runner/config.toml',
57+
String $xz_package_name, # Defaults in module hieradata
58+
Hash $runners = {},
59+
Hash $runner_defaults = {},
60+
Optional[Integer] $concurrent = undef,
61+
Optional[Integer] $check_interval = undef,
62+
Optional[String] $builds_dir = undef,
63+
Optional[String] $cache_dir = undef,
64+
Optional[Pattern[/.*:.+/]] $metrics_server = undef,
65+
Optional[Pattern[/.*:.+/]] $listen_address = undef,
66+
Optional[String] $sentry_dsn = undef,
67+
Boolean $manage_docker = false,
68+
Boolean $manage_repo = true,
69+
String $package_ensure = installed,
70+
String $package_name = 'gitlab-runner',
71+
Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com',
72+
Optional[Stdlib::Fqdn] $repo_keyserver = undef,
73+
Optional[String] $repo_keycontent = undef,
74+
Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $repo_keysource = undef,
75+
Boolean $repo_keyweak_ssl = false,
76+
String $config_path = '/etc/gitlab-runner/config.toml',
6777
) {
6878
if $manage_docker {
6979
# workaround for cirunner issue #1617

manifests/repo.pp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
# @api private
44
#
55
class gitlab_ci_runner::repo (
6-
$repo_base_url = $gitlab_ci_runner::repo_base_url,
7-
$repo_keyserver = $gitlab_ci_runner::repo_keyserver,
8-
$package_name = $gitlab_ci_runner::package_name,
6+
$repo_base_url = $gitlab_ci_runner::repo_base_url,
7+
$repo_keyserver = $gitlab_ci_runner::repo_keyserver,
8+
$repo_keyid = $gitlab_ci_runner::repo_keyid,
9+
$repo_keycontent = $gitlab_ci_runner::repo_keycontent,
10+
$repo_keysource = $gitlab_ci_runner::repo_keysource,
11+
$repo_keyweak_ssl = $gitlab_ci_runner::repo_keyweak_ssl,
12+
$package_name = $gitlab_ci_runner::package_name,
913
) {
1014
assert_private()
1115
case $facts['os']['family'] {
@@ -15,8 +19,11 @@
1519
location => "${repo_base_url}/runner/${package_name}/${facts['os']['distro']['id'].downcase}/",
1620
repos => 'main',
1721
key => {
18-
'id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F',
19-
'server' => $repo_keyserver,
22+
'id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F',
23+
'server' => $repo_keyserver,
24+
'content' => $repo_keycontent,
25+
'source' => $repo_keysource,
26+
'weak_ssl' => $repo_keyweak_ssl,
2027
},
2128
include => {
2229
'src' => false,

spec/classes/gitlab_ci_runner_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,40 @@
298298
end
299299
end
300300
end
301+
if facts[:os]['family'] == 'Debian'
302+
context 'with manage_repo => true and repo_keysource => http://path.to/gpg.key' do
303+
let(:params) do
304+
super().merge(
305+
manage_repo: true,
306+
repo_keysource: 'http://path.to/gpg.key'
307+
)
308+
end
309+
310+
it { is_expected.to compile }
311+
it { is_expected.to contain_class('gitlab_ci_runner::repo') }
312+
313+
it do
314+
is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', 'source' => 'http://path.to/gpg.key')
315+
end
316+
end
317+
end
318+
if facts[:os]['family'] == 'Debian'
319+
context 'with manage_repo => true and repo_keycontent => "somebase64encodedContent"' do
320+
let(:params) do
321+
super().merge(
322+
manage_repo: true,
323+
repo_keycontent: 'somebase64encodedContent'
324+
)
325+
end
326+
327+
it { is_expected.to compile }
328+
it { is_expected.to contain_class('gitlab_ci_runner::repo') }
329+
330+
it do
331+
is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', 'content' => 'somebase64encodedContent')
332+
end
333+
end
334+
end
301335
end
302336
end
303337
end

0 commit comments

Comments
 (0)