Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for a custom apt source release #1561

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/os/Ubuntu/18.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
postgresql::repo::baseurl: https://apt-archive.postgresql.org/pub/repos/apt/
postgresql::repo::release: "%{facts.os.distro.codename}-pgdg-archive"
Comment on lines +2 to +3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having archive repos is much cleaner than using a different distro. I much prefer this.

3 changes: 3 additions & 0 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#
# @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 apt_source_release Overrides the default release for the apt source.
#
# @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 @@ -150,6 +151,7 @@
Optional[String[1]] $repo_proxy = undef,
Optional[String[1]] $repo_baseurl = undef,
Optional[String[1]] $yum_repo_commonurl = undef,
Optional[String[1]] $apt_source_release = undef,

Optional[Boolean] $needs_initdb = undef,

Expand Down Expand Up @@ -271,6 +273,7 @@
proxy => $repo_proxy,
baseurl => $repo_baseurl,
commonurl => $yum_repo_commonurl,
release => $apt_source_release,
}
}

Expand Down
1 change: 1 addition & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# @api private
class postgresql::repo (
Optional[String[1]] $version = undef,
Optional[String[1]] $release = undef,
Optional[String[1]] $proxy = undef,
Optional[String[1]] $baseurl = undef,
Optional[String[1]] $commonurl = undef,
Expand Down
6 changes: 4 additions & 2 deletions manifests/repo/apt_postgresql_org.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
# http://www.postgresql.org/download/linux/debian/
#
$default_baseurl = 'https://apt.postgresql.org/pub/repos/apt/'

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

$default_release = "${facts['os']['distro']['codename']}-pgdg"
$_release = pick($postgresql::repo::release, $default_release)

apt::pin { 'apt_postgresql_org':
originator => 'apt.postgresql.org',
priority => 500,
}
-> apt::source { 'apt.postgresql.org':
location => $_baseurl,
release => "${facts['os']['distro']['codename']}-pgdg",
release => $_release,
repos => 'main',
architecture => $facts['os']['architecture'],
key => {
Expand Down
23 changes: 23 additions & 0 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,28 @@
it 'instantiates apt_postgresql_org class' do
expect(subject).to contain_class('postgresql::repo::apt_postgresql_org')
end

it {
is_expected.to contain_apt__source('apt.postgresql.org')
.with_location('https://apt.postgresql.org/pub/repos/apt/')
.with_release("#{facts[:os]['distro']['codename']}-pgdg")
}

it { is_expected.to contain_apt__pin('apt_postgresql_org') }
end

describe 'with custom baseurl and release' do
let(:params) do
{
baseurl: 'https://apt-archive.postgresql.org/pub/repos/apt/',
release: 'bionic-pgdg-archive',
}
end

it {
is_expected.to contain_apt__source('apt.postgresql.org')
.with_location(params[:baseurl])
.with_release(params[:release])
}
end
end
Loading