Skip to content

Commit

Permalink
Add new common Yum repo which contains add-ons
Browse files Browse the repository at this point in the history
  • Loading branch information
jorhett committed Apr 7, 2021
1 parent 3099cf4 commit 13d7fe8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
9 changes: 6 additions & 3 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
# @param repo_proxy Sets the proxy option for the official PostgreSQL yum-repositories only.
#
# @param repo_baseurl Sets the baseurl for the PostgreSQL repository. Useful if you host your own mirror of the repository.
# @param yum_repo_commonurl Sets the url for the PostgreSQL common Yum repository. Useful if you host your own mirror of the YUM repository.
#
# @param needs_initdb Explicitly calls the initdb operation after the server package is installed and before the PostgreSQL service is started.
#
Expand Down Expand Up @@ -142,6 +143,7 @@
$postgis_version = undef,
$repo_proxy = undef,
$repo_baseurl = undef,
$yum_repo_commonurl = undef,

$needs_initdb = undef,

Expand Down Expand Up @@ -265,9 +267,10 @@
# Setup of the repo only makes sense globally, so we are doing this here.
if($manage_package_repo) {
class { 'postgresql::repo':
version => $globals_version,
proxy => $repo_proxy,
baseurl => $repo_baseurl,
version => $globals_version,
proxy => $repo_proxy,
baseurl => $repo_baseurl,
commonurl => $yum_repo_commonurl,
}
}

Expand Down
1 change: 1 addition & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$version = undef,
$proxy = undef,
$baseurl = undef,
$commonurl = undef,
) {
case $facts['os']['family'] {
'RedHat', 'Linux': {
Expand Down
11 changes: 11 additions & 0 deletions manifests/repo/yum_postgresql_org.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
$label2 = 'rhel'
}
$default_baseurl = "https://download.postgresql.org/pub/repos/yum/${postgresql::repo::version}/${label1}/${label2}-\$releasever-\$basearch"
$default_commonurl = "https://download.postgresql.org/pub/repos/yum/common/${label1}/${label2}-\$releasever-\$basearch"

$_baseurl = pick($postgresql::repo::baseurl, $default_baseurl)
$_commonurl = pick($postgresql::repo::commonurl, $default_commonurl)

yumrepo { 'yum.postgresql.org':
descr => "PostgreSQL ${postgresql::repo::version} \$releasever - \$basearch",
Expand All @@ -32,5 +34,14 @@
proxy => $postgresql::repo::proxy,
}

yumrepo { 'pgdg-common':
descr => "PostgreSQL common RPMs \$releasever - \$basearch",
baseurl => $_commonurl,
enabled => 1,
gpgcheck => 1,
gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}",
proxy => $postgresql::repo::proxy,
}

Yumrepo['yum.postgresql.org'] -> Package<|tag == 'puppetlabs-postgresql'|>
}
13 changes: 11 additions & 2 deletions spec/unit/classes/globals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@
'enabled' => '1',
'proxy' => 'http://proxy-server:8080',
)
is_expected.to contain_yumrepo('pgdg-common').with(
'enabled' => '1',
'proxy' => 'http://proxy-server:8080',
)
end
end

describe 'repo_baseurl on RHEL => mirror.localrepo.com' do
let(:params) do
{
manage_package_repo: true,
repo_baseurl: 'http://mirror.localrepo.com',
repo_baseurl: 'http://mirror.localrepo.com/pgdg-postgresql',
yum_repo_commonurl: 'http://mirror.localrepo.com/pgdg-common',
}
end

Expand All @@ -93,7 +98,11 @@
it do
is_expected.to contain_yumrepo('yum.postgresql.org').with(
'enabled' => '1',
'baseurl' => 'http://mirror.localrepo.com',
'baseurl' => 'http://mirror.localrepo.com/pgdg-postgresql',
)
is_expected.to contain_yumrepo('pgdg-common').with(
'enabled' => '1',
'baseurl' => 'http://mirror.localrepo.com/pgdg-common',
)
end
end
Expand Down

0 comments on commit 13d7fe8

Please sign in to comment.