Skip to content

Commit 08b7bdb

Browse files
committed
Merge pull request puppetlabs#172 from dprince/python_module
Adds new postgresql::python module.
2 parents 8aa9165 + 03b3df3 commit 08b7bdb

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
}
135135

136136
$service_status = undef
137+
$python_package_name="python-psycopg2"
137138
}
138139

139140
'Debian': {
@@ -166,6 +167,7 @@
166167
$datadir = pick($custom_datadir, "/var/lib/postgresql/${version}/main")
167168
$confdir = pick($custom_confdir, "/etc/postgresql/${version}/main")
168169
$service_status = "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'"
170+
$python_package_name = "python-psycopg2"
169171
}
170172

171173
default: {

manifests/python.pp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Class: postgresql::python
2+
# This class installs the python libs for postgresql.
3+
#
4+
# Parameters:
5+
# [*ensure*] - ensure state for package.
6+
# can be specified as version.
7+
# [*package_name*] - name of package
8+
class postgresql::python(
9+
$package_name = $postgresql::params::python_package_name,
10+
$package_ensure = 'present'
11+
) inherits postgresql::params {
12+
13+
package { 'python-psycopg2':
14+
ensure => $package_ensure,
15+
name => $package_name,
16+
}
17+
18+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require 'spec_helper'
2+
3+
describe 'postgresql::python', :type => :class do
4+
5+
describe 'on a redhat based os' do
6+
let :facts do {
7+
:osfamily => 'RedHat',
8+
:postgres_default_version => 'foo',
9+
}
10+
end
11+
it { should contain_package('python-psycopg2').with(
12+
:name => 'python-psycopg2',
13+
:ensure => 'present'
14+
)}
15+
end
16+
17+
describe 'on a debian based os' do
18+
let :facts do {
19+
:osfamily => 'Debian',
20+
:postgres_default_version => 'foo',
21+
}
22+
end
23+
it { should contain_package('python-psycopg2').with(
24+
:name => 'python-psycopg2',
25+
:ensure => 'present'
26+
)}
27+
end
28+
29+
describe 'on any other os' do
30+
let :facts do {
31+
:osfamily => 'foo',
32+
:postgres_default_version => 'foo',
33+
}
34+
end
35+
36+
it 'should fail' do
37+
expect { subject }.to raise_error(/Unsupported osfamily: foo/)
38+
end
39+
end
40+
41+
end

0 commit comments

Comments
 (0)