Skip to content

Commit

Permalink
Merge pull request #271 from tequeter/fix-yumrepos
Browse files Browse the repository at this point in the history
 fix repositories missing the edition name
  • Loading branch information
LongLiveCHIEF authored Sep 22, 2018
2 parents 48fbf8b + 7573a17 commit 936a433
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 33 deletions.
10 changes: 8 additions & 2 deletions data/Debian.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
gitlab::repository_configuration:
'apt::source':
"gitlab_official_%{lookup('gitlab::edition')}":
"gitlab_official_ce":
comment: 'Official repository for GitLab Omnibus'
location: "https://packages.gitlab.com/gitlab/gitlab-%{lookup('gitlab::edition')}/debian"
location: "https://packages.gitlab.com/gitlab/gitlab-ce/debian"
key:
id: '1A4C919DB987D435939638B914219A96E15E78F4'
source: 'https://packages.gitlab.com/gpg.key'
"gitlab_official_ee":
comment: 'Official repository for GitLab Omnibus'
location: "https://packages.gitlab.com/gitlab/gitlab-ee/debian"
key:
id: '1A4C919DB987D435939638B914219A96E15E78F4'
source: 'https://packages.gitlab.com/gpg.key'
11 changes: 10 additions & 1 deletion data/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
gitlab::repository_configuration:
yumrepo:
"gitlab_official_%{lookup('gitlab::edition')}":
"gitlab_official_ce":
ensure: 'present'
assumeyes: true
enabled: 1
baseurl: "https://packages.gitlab.com/gitlab/gitlab-ce/el/%{facts.os.release.major}/$basearch"
gpgkey: "https://packages.gitlab.com/gpg.key"
gpgcheck: 1
repo_gpgcheck: 1
sslverify: 1
"gitlab_official_ee":
ensure: 'present'
assumeyes: true
enabled: 1
Expand Down
47 changes: 21 additions & 26 deletions manifests/omnibus_package_repository.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,30 @@
$_edition = $manage_upstream_edition
}

# ensure the correct edition is used if upstream package repositories are being configured
if $_edition != 'disabled'{
case $facts['os']['family'] {
'Debian': {
$_filtered_repository_configuration = {
'apt::source' => {
"gitlab_official_${_edition}" => {
location => "https://packages.gitlab.com/gitlab/gitlab-${_edition}/debian",
},
},
}
}
'RedHat': {
$_filtered_repository_configuration = {
'yumrepo' => {
"gitlab_official_${_edition}" => {
baseurl => "https://packages.gitlab.com/gitlab/gitlab-${_edition}/el/${facts['os']['release']['major']}/\$basearch",
},
},
if $_edition == 'disabled' {
$_repository_configuration = $repository_configuration
} else {
# if we manage the repositories, adjust the ensure => present/absent
# attributes according to the desired edition.
$_repository_configuration = $repository_configuration.reduce({}) | $_memo, $_pair1 | {
# yumrepo => ...
[ $_rsc_type, $_repo_hash ] = $_pair1

$_mapped_repo_hash = $_repo_hash.reduce({}) | $_memo, $_pair2 | {
# gitlab_official_ce => ...
[ $_repo_name, $_repo_attrs, ] = $_pair2

if $_repo_name == "gitlab_official_${_edition}" {
$_ensure = 'present'
} else {
$_ensure = 'absent'
}

$_memo + { $_repo_name => $_repo_attrs + { ensure => $_ensure } }
}
default: {
$_filtered_repository_configuration = {}
}

$_memo + { $_rsc_type => $_mapped_repo_hash }
}
$_repository_configuration = deep_merge($repository_configuration, $_filtered_repository_configuration)
} else {
# using upstream repository, so just use defaults
$_repository_configuration = $repository_configuration
}

# common attributes for all repository configuration resources
Expand Down
16 changes: 12 additions & 4 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@

case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_apt__source('gitlab_official_ce') }
it { is_expected.to contain_apt__source('gitlab_official_ce').with_ensure('present').with_comment(%r{.}) }
it { is_expected.to contain_apt__source('gitlab_official_ee').with_ensure('absent') }
it { is_expected.not_to contain_apt__source('gitlab_official_') }
it { is_expected.not_to contain_yumrepo('gitlab_official_ce') }
when 'RedHat'
it { is_expected.to contain_yumrepo('gitlab_official_ce') }
it { is_expected.to contain_yumrepo('gitlab_official_ce').with_ensure('present').with_enabled(1) }
it { is_expected.to contain_yumrepo('gitlab_official_ee').with_ensure('absent') }
it { is_expected.not_to contain_yumrepo('gitlab_official_') }
it { is_expected.not_to contain_apt__source('gitlab_official_ce') }
end
end

Expand All @@ -35,9 +41,11 @@

case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_apt__source('gitlab_official_ee') }
it { is_expected.to contain_apt__source('gitlab_official_ee').with_ensure('present') }
it { is_expected.to contain_apt__source('gitlab_official_ce').with_ensure('absent') }
when 'RedHat'
it { is_expected.to contain_yumrepo('gitlab_official_ee') }
it { is_expected.to contain_yumrepo('gitlab_official_ee').with_ensure('present') }
it { is_expected.to contain_yumrepo('gitlab_official_ce').with_ensure('absent') }
end
end
describe 'external_url' do
Expand Down

0 comments on commit 936a433

Please sign in to comment.