Skip to content

Commit 5ef6751

Browse files
committed
Add DNF module management
On EL8 and Fedora DNF can manage modules. This is a method of providing multiple versions on the same OS. Only one DNF module can be active at the same time.
1 parent 25b816e commit 5ef6751

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

manifests/dnfmodule.pp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# @summary Manage the DNF module
2+
#
3+
# On EL8 and Fedora DNF can manage modules. This is a method of providing
4+
# multiple versions on the same OS. Only one DNF module can be active at the
5+
# same time.
6+
#
7+
# @api private
8+
class postgresql::dnfmodule (
9+
String[1] $ensure = 'installed',
10+
String[1] $module = 'postgresql',
11+
) {
12+
package { 'postgresql dnf module':
13+
ensure => $ensure,
14+
name => $module,
15+
enable_only => true,
16+
provider => 'dnfmodule',
17+
}
18+
19+
Package['postgresql dnf module'] -> Package<|tag == 'puppetlabs-postgresql'|>
20+
}

manifests/globals.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
# @param manage_xlogdir Set to false if you have file{ $xlogdir: } already defined
8787
#
8888
# @param manage_package_repo Sets up official PostgreSQL repositories on your host if set to true.
89+
# @param manage_dnf_module
90+
# Manage the DNF module. This only makes sense on distributions that use DNF
91+
# package manager, such as EL8 or Fedora. It also requires Puppet 5.5.20+ or
92+
# Puppet 6.15.0+ since they ship the dnfmodule provider.
8993
# @param module_workdir Specifies working directory under which the psql command should be executed. May need to specify if '/tmp' is on volume mounted with noexec option.
9094
#
9195
#
@@ -153,6 +157,7 @@
153157
$manage_selinux = undef,
154158

155159
$manage_package_repo = undef,
160+
Boolean $manage_dnf_module = false,
156161
$module_workdir = undef,
157162
) {
158163
# We are determining this here, because it is needed by the package repo
@@ -264,5 +269,9 @@
264269
proxy => $repo_proxy,
265270
baseurl => $repo_baseurl,
266271
}
272+
} elsif $manage_dnf_module {
273+
class { 'postgresql::dnfmodule':
274+
ensure => $globals_version,
275+
}
267276
}
268277
}

spec/unit/classes/client_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@
4343
end
4444
end
4545

46+
describe 'with manage_dnf_module true' do
47+
let(:pre_condition) do
48+
<<-PUPPET
49+
class { 'postgresql::globals':
50+
manage_dnf_module => true,
51+
}
52+
PUPPET
53+
end
54+
55+
it { is_expected.to contain_package('postgresql dnf module').that_comes_before('Package[postgresql-client]') }
56+
end
57+
4658
describe 'with client package name explicitly set undef' do
4759
let :params do
4860
{

spec/unit/classes/server_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
end
3636
end
3737

38+
describe 'with manage_dnf_module true' do
39+
let(:pre_condition) do
40+
<<-PUPPET
41+
class { 'postgresql::globals':
42+
manage_dnf_module => true,
43+
}
44+
PUPPET
45+
end
46+
47+
it { is_expected.to contain_package('postgresql dnf module').that_comes_before('Package[postgresql-server]') }
48+
end
49+
3850
describe 'service_ensure => running' do
3951
let(:params) do
4052
{

0 commit comments

Comments
 (0)