Skip to content

Commit fda546f

Browse files
committed
Avoid dependency cycles with glibc-langpack-en
By calling stdlib::ensure_packages() in the class itself the resource gets tied to the class. If other packages also depend on the resource, you can get dependency cycles. In particular, candlepin also does this and that causes a dependency cycle. By using a class that is included the resource "floats" in the catalog. We then only ensure the package is installed somewhere before we create the database. Link: theforeman/puppet-candlepin@ca77145 Fixes: 768a54e ("Ensure glibc-langpack-en is always installed on EL")
1 parent 9881651 commit fda546f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

manifests/database/postgresql.pp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
}
77

88
include postgresql::client, postgresql::server
9-
10-
if $facts['os']['family'] == 'RedHat' {
11-
stdlib::ensure_packages(['glibc-langpack-en'])
12-
Package['glibc-langpack-en'] -> Postgresql::Server::Db[$foreman::db_database]
13-
}
9+
include foreman::database::postgresql::encoding
1410

1511
postgresql::server::db { $foreman::db_database:
1612
user => $foreman::db_username,
1713
password => postgresql::postgresql_password($foreman::db_username, $foreman::db_password),
1814
owner => $foreman::db_username,
1915
encoding => 'utf8',
2016
locale => 'en_US.utf8',
17+
require => Class['foreman::database::postgresql::encoding'],
2118
}
2219
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @summary Class to ensure the packages for encoding are installed
2+
# @api private
3+
class foreman::database::postgresql::encoding {
4+
if $facts['os']['family'] == 'RedHat' {
5+
stdlib::ensure_packages(['glibc-langpack-en'])
6+
}
7+
}

spec/classes/foreman_database_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
require 'spec_helper'
22

33
describe 'foreman' do
4-
on_supported_os.each do |os, facts|
4+
on_supported_os.each do |os, os_facts|
55
context "on #{os}" do
6-
let(:facts) { facts }
6+
let(:facts) { os_facts }
77
let(:params) { {} }
88

9+
if os_facts[:os]['family'] == 'RedHat'
10+
it { should contain_package('glibc-langpack-en').that_comes_before('Postgresql::Server::Db[foreman]') }
11+
else
12+
it { should_not contain_package('glibc-langpack-en') }
13+
end
14+
915
describe 'with db_manage set to false' do
1016
let(:params) { super().merge(db_manage: false) }
1117

0 commit comments

Comments
 (0)