Skip to content

Commit 010ed69

Browse files
authored
Merge pull request #1561 from h0tw1r3/fix-ubuntu-18-repo
support for a custom apt source release
2 parents 26011ea + 29ef7ff commit 010ed69

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

Diff for: data/os/Ubuntu/18.04.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
postgresql::repo::baseurl: https://apt-archive.postgresql.org/pub/repos/apt/
3+
postgresql::repo::release: "%{facts.os.distro.codename}-pgdg-archive"

Diff for: manifests/globals.pp

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#
6161
# @param repo_baseurl Sets the baseurl for the PostgreSQL repository. Useful if you host your own mirror of the repository.
6262
# @param yum_repo_commonurl Sets the url for the PostgreSQL common Yum repository. Useful if you host your own mirror of the YUM repository.
63+
# @param apt_source_release Overrides the default release for the apt source.
6364
#
6465
# @param needs_initdb
6566
# Explicitly calls the initdb operation after the server package is installed and before the PostgreSQL service is started.
@@ -150,6 +151,7 @@
150151
Optional[String[1]] $repo_proxy = undef,
151152
Optional[String[1]] $repo_baseurl = undef,
152153
Optional[String[1]] $yum_repo_commonurl = undef,
154+
Optional[String[1]] $apt_source_release = undef,
153155

154156
Optional[Boolean] $needs_initdb = undef,
155157

@@ -271,6 +273,7 @@
271273
proxy => $repo_proxy,
272274
baseurl => $repo_baseurl,
273275
commonurl => $yum_repo_commonurl,
276+
release => $apt_source_release,
274277
}
275278
}
276279

Diff for: manifests/repo.pp

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# @api private
22
class postgresql::repo (
33
Optional[String[1]] $version = undef,
4+
Optional[String[1]] $release = undef,
45
Optional[String[1]] $proxy = undef,
56
Optional[String[1]] $baseurl = undef,
67
Optional[String[1]] $commonurl = undef,

Diff for: manifests/repo/apt_postgresql_org.pp

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77
# http://www.postgresql.org/download/linux/debian/
88
#
99
$default_baseurl = 'https://apt.postgresql.org/pub/repos/apt/'
10-
1110
$_baseurl = pick($postgresql::repo::baseurl, $default_baseurl)
1211

12+
$default_release = "${facts['os']['distro']['codename']}-pgdg"
13+
$_release = pick($postgresql::repo::release, $default_release)
14+
1315
apt::pin { 'apt_postgresql_org':
1416
originator => 'apt.postgresql.org',
1517
priority => 500,
1618
}
1719
-> apt::source { 'apt.postgresql.org':
1820
location => $_baseurl,
19-
release => "${facts['os']['distro']['codename']}-pgdg",
21+
release => $_release,
2022
repos => 'main',
2123
architecture => $facts['os']['architecture'],
2224
key => {

Diff for: spec/classes/repo_spec.rb

+23
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,28 @@
99
it 'instantiates apt_postgresql_org class' do
1010
expect(subject).to contain_class('postgresql::repo::apt_postgresql_org')
1111
end
12+
13+
it {
14+
is_expected.to contain_apt__source('apt.postgresql.org')
15+
.with_location('https://apt.postgresql.org/pub/repos/apt/')
16+
.with_release("#{facts[:os]['distro']['codename']}-pgdg")
17+
}
18+
19+
it { is_expected.to contain_apt__pin('apt_postgresql_org') }
20+
end
21+
22+
describe 'with custom baseurl and release' do
23+
let(:params) do
24+
{
25+
baseurl: 'https://apt-archive.postgresql.org/pub/repos/apt/',
26+
release: 'bionic-pgdg-archive',
27+
}
28+
end
29+
30+
it {
31+
is_expected.to contain_apt__source('apt.postgresql.org')
32+
.with_location(params[:baseurl])
33+
.with_release(params[:release])
34+
}
1235
end
1336
end

0 commit comments

Comments
 (0)