Merge pull request #189 from kbarber/feature/master/support-more-distroz
Add more distributions
This commit is contained in:
commit
4e668dd69e
7 changed files with 140 additions and 36 deletions
|
@ -19,6 +19,8 @@ class postgresql::contrib (
|
||||||
$package_ensure = 'present'
|
$package_ensure = 'present'
|
||||||
) inherits postgresql::params {
|
) inherits postgresql::params {
|
||||||
|
|
||||||
|
validate_string($package_name)
|
||||||
|
|
||||||
package { 'postgresql-contrib':
|
package { 'postgresql-contrib':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
name => $package_name,
|
name => $package_name,
|
||||||
|
|
|
@ -17,6 +17,8 @@ class postgresql::devel(
|
||||||
$package_ensure = 'present'
|
$package_ensure = 'present'
|
||||||
) inherits postgresql::params {
|
) inherits postgresql::params {
|
||||||
|
|
||||||
|
validate_string($package_name)
|
||||||
|
|
||||||
package { 'postgresql-devel':
|
package { 'postgresql-devel':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
name => $package_name,
|
name => $package_name,
|
||||||
|
|
|
@ -19,6 +19,8 @@ class postgresql::java (
|
||||||
$package_ensure = 'present'
|
$package_ensure = 'present'
|
||||||
) inherits postgresql::params {
|
) inherits postgresql::params {
|
||||||
|
|
||||||
|
validate_string($package_name)
|
||||||
|
|
||||||
package { 'postgresql-jdbc':
|
package { 'postgresql-jdbc':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
name => $package_name,
|
name => $package_name,
|
||||||
|
|
|
@ -56,7 +56,6 @@ class postgresql::params(
|
||||||
# TODO: figure out a way to make this not platform-specific
|
# TODO: figure out a way to make this not platform-specific
|
||||||
$manage_redhat_firewall = false
|
$manage_redhat_firewall = false
|
||||||
|
|
||||||
|
|
||||||
if ($manage_package_repo) {
|
if ($manage_package_repo) {
|
||||||
case $::osfamily {
|
case $::osfamily {
|
||||||
'RedHat': {
|
'RedHat': {
|
||||||
|
@ -80,7 +79,7 @@ class postgresql::params(
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian")
|
fail("Unsupported osfamily for manage_package_repo: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports managing repos for osfamily RedHat and Debian")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +174,59 @@ class postgresql::params(
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian")
|
|
||||||
|
$err_msg_prefix = "Module ${module_name} does not provide defaults for osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}; please specify a value for ${module_name}::params::"
|
||||||
|
|
||||||
|
if ($run_initdb != undef) {
|
||||||
|
$needs_initdb = $run_initdb
|
||||||
|
} else {
|
||||||
|
fail("${err_msg_prefix}run_initdb")
|
||||||
|
}
|
||||||
|
|
||||||
|
$firewall_supported = false
|
||||||
|
|
||||||
|
if ($custom_service_name) {
|
||||||
|
$service_name = $custom_service_name
|
||||||
|
} else {
|
||||||
|
fail("${err_msg_prefix}custom_service_name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($custom_client_package_name) {
|
||||||
|
$client_package_name = $custom_client_package_name
|
||||||
|
} else {
|
||||||
|
fail("${err_msg_prefix}custom_client_package_name")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($custom_server_package_name) {
|
||||||
|
$server_package_name = $custom_server_package_name
|
||||||
|
} else {
|
||||||
|
fail("${err_msg_prefix}custom_server_package_name")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$contrib_package_name = $custom_contrib_package_name
|
||||||
|
$devel_package_name = $custom_devel_package_name
|
||||||
|
$java_package_name = $custom_java_package_name
|
||||||
|
|
||||||
|
if ($custom_bindir) {
|
||||||
|
$bindir = $custom_bindir
|
||||||
|
} else {
|
||||||
|
fail("${err_msg_prefix}custom_bindir")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($custom_datadir) {
|
||||||
|
$datadir = $custom_datadir
|
||||||
|
} else {
|
||||||
|
fail("${err_msg_prefix}custom_datadir")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($custom_confdir) {
|
||||||
|
$confdir = $custom_confdir
|
||||||
|
} else {
|
||||||
|
fail("${err_msg_prefix}custom_confdir")
|
||||||
|
}
|
||||||
|
|
||||||
|
$service_status = undef
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'postgresql', :type => :class do
|
describe 'postgresql', :type => :class do
|
||||||
|
describe 'with supported os' do
|
||||||
let :facts do
|
let :facts do
|
||||||
{
|
{
|
||||||
:postgres_default_version => '8.4',
|
:postgres_default_version => '8.4',
|
||||||
|
@ -34,3 +35,37 @@ describe 'postgresql', :type => :class do
|
||||||
it { should include_class("postgresql::params") }
|
it { should include_class("postgresql::params") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'with unsupported os' do
|
||||||
|
let :facts do
|
||||||
|
{
|
||||||
|
:postgres_default_version => '8.4',
|
||||||
|
:osfamily => 'foo',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'support override params' do
|
||||||
|
let(:params) {{
|
||||||
|
:version => '8.4',
|
||||||
|
:package_source => '',
|
||||||
|
:locale => 'en_NG',
|
||||||
|
:charset => 'UTF8',
|
||||||
|
:datadir => '/srv/pgdata',
|
||||||
|
:confdir => '/opt/pg/etc',
|
||||||
|
:bindir => '/opt/pg/bin',
|
||||||
|
:client_package_name => 'my-postgresql-client',
|
||||||
|
:server_package_name => 'my-postgresql-server',
|
||||||
|
:contrib_package_name => 'my-postgresql-contrib',
|
||||||
|
:devel_package_name => 'my-postgresql-devel',
|
||||||
|
:java_package_name => 'my-postgresql-java',
|
||||||
|
:service_name => 'my-postgresql',
|
||||||
|
:user => 'my-postgresql',
|
||||||
|
:group => 'my-postgresql',
|
||||||
|
:run_initdb => true,
|
||||||
|
}}
|
||||||
|
|
||||||
|
it { should include_class("postgresql") }
|
||||||
|
it { should include_class("postgresql::params") }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -42,8 +42,8 @@ describe 'postgresql::java', :type => :class do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail' do
|
it 'should fail without all the necessary parameters' do
|
||||||
expect { subject }.to raise_error(/Unsupported osfamily: foo/)
|
expect { subject }.to raise_error(/Module postgresql does not provide defaults for osfamily: foo/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,20 @@ describe 'postgresql::python', :type => :class do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should fail without all the necessary parameters' do
|
||||||
|
expect { subject }.to raise_error(/Module postgresql does not provide defaults for osfamily: foo/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'on any other os without all the necessary parameters' do
|
||||||
|
let :facts do {
|
||||||
|
:osfamily => 'foo',
|
||||||
|
:postgres_default_version => 'foo',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
it 'should fail' do
|
it 'should fail' do
|
||||||
expect { subject }.to raise_error(/Unsupported osfamily: foo/)
|
expect { subject }.to raise_error(/Module postgresql does not provide defaults for osfamily: foo/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue