Skip to content

Commit

Permalink
Add parameters to apt::source to avoid requiring an internet connexion
Browse files Browse the repository at this point in the history
Signed-off-by: Cedric Couralet <[email protected]>
Signed-off-by: Cédric Couralet <[email protected]>
  • Loading branch information
micedre committed Jun 14, 2021
1 parent 5de3a87 commit ea8fd90
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 23 deletions.
40 changes: 20 additions & 20 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@
# The path to the config file of Gitlab runner.
#
class gitlab_ci_runner (
String $xz_package_name, # Defaults in module hieradata
Hash $runners = {},
Hash $runner_defaults = {},
Optional[Integer] $concurrent = undef,
Optional[Integer] $check_interval = undef,
Optional[String] $builds_dir = undef,
Optional[String] $cache_dir = undef,
Optional[Pattern[/.*:.+/]] $metrics_server = undef,
Optional[Pattern[/.*:.+/]] $listen_address = undef,
Optional[String] $sentry_dsn = undef,
Boolean $manage_docker = false,
Boolean $manage_repo = true,
String $package_ensure = installed,
String $package_name = 'gitlab-runner',
Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com',
Optional[Stdlib::Fqdn] $repo_keyserver = undef,
Optional[String] $repo_keycontent = undef,
Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $repo_keysource = undef,
Boolean $repo_keyweak_ssl = false,
String $config_path = '/etc/gitlab-runner/config.toml',
String $xz_package_name, # Defaults in module hieradata
Hash $runners = {},
Hash $runner_defaults = {},
Optional[Integer] $concurrent = undef,
Optional[Integer] $check_interval = undef,
Optional[String] $builds_dir = undef,
Optional[String] $cache_dir = undef,
Optional[Pattern[/.*:.+/]] $metrics_server = undef,
Optional[Pattern[/.*:.+/]] $listen_address = undef,
Optional[String] $sentry_dsn = undef,
Boolean $manage_docker = false,
Boolean $manage_repo = true,
String $package_ensure = installed,
String $package_name = 'gitlab-runner',
Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com',
Optional[Stdlib::Fqdn] $repo_keyserver = undef,
Optional[String] $repo_keycontent = undef,
Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $repo_keysource = undef,
Boolean $repo_keyweak_ssl = false,
String $config_path = '/etc/gitlab-runner/config.toml',
) {
if $manage_docker {
# workaround for cirunner issue #1617
Expand Down
1 change: 0 additions & 1 deletion manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
class gitlab_ci_runner::repo (
$repo_base_url = $gitlab_ci_runner::repo_base_url,
$repo_keyserver = $gitlab_ci_runner::repo_keyserver,
$repo_keyid = $gitlab_ci_runner::repo_keyid,
$repo_keycontent = $gitlab_ci_runner::repo_keycontent,
$repo_keysource = $gitlab_ci_runner::repo_keysource,
$repo_keyweak_ssl = $gitlab_ci_runner::repo_keyweak_ssl,
Expand Down
41 changes: 39 additions & 2 deletions spec/classes/gitlab_ci_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@
repos: 'main',
key: {
'id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F',
'server' => undef_value
'server' => undef_value,
'content' => undef_value,
'source' => undef_value,
'weak_ssl' => false,
},
include: {
'src' => false,
Expand Down Expand Up @@ -294,7 +297,41 @@
it { is_expected.to contain_class('gitlab_ci_runner::repo') }

it do
is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', 'server' => 'keys.gnupg.net')
is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', 'server' => 'keys.gnupg.net', 'content' => undef_value, 'source' => undef_value, 'weak_ssl' => false)
end
end
end
if facts[:os]['family'] == 'Debian'
context 'with manage_repo => true and repo_keysource => http://path.to/gpg.key' do
let(:params) do
super().merge(
manage_repo: true,
repo_keysource: 'http://path.to/gpg.key'
)
end

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

it do
is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', "server"=> undef_value, "content"=> undef_value, 'source' => 'http://path.to/gpg.key', 'weak_ssl' => false)
end
end
end
if facts[:os]['family'] == 'Debian'
context 'with manage_repo => true and repo_keycontent => "somebase64encodedContent"' do
let(:params) do
super().merge(
manage_repo: true,
repo_keycontent: 'somebase64encodedContent'
)
end

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

it do
is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', "server"=> undef_value, 'content' => 'somebase64encodedContent','source' => undef_value, 'weak_ssl' => false)
end
end
end
Expand Down

0 comments on commit ea8fd90

Please sign in to comment.