Skip to content

Commit 1eb45d0

Browse files
author
Alexander Brovman
committed
adding proxy option for yum repositories
1 parent 7981b09 commit 1eb45d0

File tree

6 files changed

+74
-19
lines changed

6 files changed

+74
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
### Summary
3+
- support setting a proxy for yum operations
4+
15
## 2015-07-07 - Supported Release 4.4.2
26
### Summary
37
This release fixes a bug introduced in 4.4.0.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ This will set the default encoding encoding for all databases created with this
301301
####`locale`
302302
This will set the default database locale for all databases created with this module. On certain operating systems this will be used during the `template1` initialization as well so it becomes a default outside of the module as well. Defaults to `undef` which is effectively `C`.
303303

304+
####`repo_proxy`
305+
This will set the proxy option for the official PostgreSQL yum-repositories only, Debian is currently not supported. This is useful if your server is behind a corporate firewall and needs to use proxyservers for outside connectivity.
306+
307+
304308
#####Debian
305309

306310
On Debian you'll need to ensure that the 'locales-all' package is installed for full functionality of Postgres.

manifests/globals.pp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
$version = undef,
4343
$postgis_version = undef,
44+
$repo_proxy = undef,
4445

4546
$needs_initdb = undef,
4647

@@ -70,6 +71,12 @@
7071
/^5\./ => '8.1',
7172
default => undef,
7273
},
74+
default => $::operatingsystemrelease ? {
75+
/^7\./ => '9.2',
76+
/^6\./ => '8.4',
77+
/^5\./ => '8.1',
78+
default => undef,
79+
},
7380
},
7481
'Debian' => $::operatingsystem ? {
7582
'Debian' => $::operatingsystemrelease ? {
@@ -131,7 +138,8 @@
131138
# Setup of the repo only makes sense globally, so we are doing this here.
132139
if($manage_package_repo) {
133140
class { 'postgresql::repo':
134-
version => $globals_version
141+
version => $globals_version,
142+
proxy => $repo_proxy,
135143
}
136144
}
137145
}

manifests/repo.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PRIVATE CLASS: do not use directly
22
class postgresql::repo (
3-
$version = undef
3+
$version = undef,
4+
$proxy = undef,
45
) inherits postgresql::params {
56
case $::osfamily {
67
'RedHat', 'Linux': {

manifests/repo/yum_postgresql_org.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
enabled => 1,
2424
gpgcheck => 1,
2525
gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}",
26+
proxy => $postgresql::repo::proxy,
2627
}
2728

2829
Yumrepo['yum.postgresql.org'] -> Package<|tag == 'postgresql'|>

spec/unit/classes/globals_spec.rb

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

33
describe 'postgresql::globals', :type => :class do
4-
let :facts do
5-
{
6-
:osfamily => 'Debian',
7-
:operatingsystem => 'Debian',
8-
:operatingsystemrelease => '6.0',
9-
:lsbdistid => 'Debian',
10-
:lsbdistcodename => 'squeeze',
11-
}
12-
end
4+
context "on a debian 6" do
5+
let (:facts) do
6+
{
7+
:osfamily => 'Debian',
8+
:operatingsystem => 'Debian',
9+
:operatingsystemrelease => '6.0',
10+
:lsbdistid => 'Debian',
11+
:lsbdistcodename => 'squeeze',
12+
}
13+
end
1314

14-
describe 'with no parameters' do
15-
it 'should work' do
16-
is_expected.to contain_class("postgresql::globals")
15+
describe 'with no parameters' do
16+
it 'should work' do
17+
is_expected.to contain_class("postgresql::globals")
18+
end
19+
end
20+
21+
describe 'manage_package_repo => true' do
22+
let(:params) do
23+
{
24+
:manage_package_repo => true,
25+
}
26+
end
27+
it 'should pull in class postgresql::repo' do
28+
is_expected.to contain_class("postgresql::repo")
29+
end
1730
end
1831
end
1932

20-
describe 'manage_package_repo => true' do
21-
let(:params) do
33+
context 'on redhat family systems' do
34+
let (:facts) do
2235
{
23-
:manage_package_repo => true,
36+
:osfamily => 'RedHat',
37+
:operatingsystem => 'RedHat',
38+
:operatingsystemrelease => '7.1',
2439
}
2540
end
26-
it 'should pull in class postgresql::repo' do
27-
is_expected.to contain_class("postgresql::repo")
41+
describe 'with no parameters' do
42+
it 'should work' do
43+
is_expected.to contain_class("postgresql::globals")
44+
end
45+
end
46+
47+
describe 'manage_package_repo on RHEL => true' do
48+
let(:params) do
49+
{
50+
:manage_package_repo => true,
51+
:repo_proxy => 'http://proxy-server:8080',
52+
}
53+
end
54+
55+
it 'should pull in class postgresql::repo' do
56+
is_expected.to contain_class("postgresql::repo")
57+
end
58+
59+
it do
60+
should contain_yumrepo('yum.postgresql.org').with(
61+
'enabled' => '1',
62+
'proxy' => 'http://proxy-server:8080'
63+
)
64+
end
2865
end
2966
end
3067
end

0 commit comments

Comments
 (0)