diff --git a/data/Debian.yaml b/data/Debian.yaml index 26624230..3b54f537 100644 --- a/data/Debian.yaml +++ b/data/Debian.yaml @@ -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' diff --git a/data/RedHat.yaml b/data/RedHat.yaml index 46937d63..d4012451 100644 --- a/data/RedHat.yaml +++ b/data/RedHat.yaml @@ -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 diff --git a/manifests/omnibus_package_repository.pp b/manifests/omnibus_package_repository.pp index 64d87727..83a52611 100644 --- a/manifests/omnibus_package_repository.pp +++ b/manifests/omnibus_package_repository.pp @@ -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 diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 4472a738..89b916b8 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -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 @@ -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