forked from puppetlabs/puppetlabs-postgresql
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit creates a new class called `package_source_info`, which has some initial framework for managing the postgresql.org yumrepo. It also serves as a container for the 'version' variable that is needed by the 'platform' class in order to use other versions of postgres besides the system default.
- Loading branch information
Chris Price
committed
Dec 3, 2012
1 parent
663c779
commit fa24f24
Showing
9 changed files
with
164 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class postgresql::package_source::yum_postgresql_org( | ||
$version | ||
) { | ||
|
||
$version_parts = split($version, '[.]') | ||
$package_version = "${version_parts[0]}${version_parts[1]}" | ||
|
||
file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}": | ||
source => "puppet:///modules/postgresql_tests/RPM-GPG-KEY-PGDG-${package_version}" | ||
} -> | ||
|
||
yumrepo { "yum.postgresql.org": | ||
descr => "PostgreSQL ${version} \$releasever - \$basearch", | ||
baseurl => "http://yum.postgresql.org/${version}/redhat/rhel-\$releasever-\$basearch", | ||
enabled => 1, | ||
gpgcheck => 1, | ||
gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}", | ||
} | ||
|
||
if defined(Package['postgresql-server']) { | ||
Yumrepo['yum.postgresql.org'] -> Package['postgresql-server'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# TODO: add real docs | ||
|
||
# This class allows you to use a newer version of postgres, rather than your | ||
# system's default version. | ||
# | ||
# Note that it is important that you use the '->', or a | ||
# before/require metaparameter to make sure that the `package_source_info` | ||
# class is evaluated before any of the other classes in the module. | ||
# | ||
# Also note that this class includes the ability to automatically manage | ||
# the yumrepo resource. If you'd prefer to manage the repo yourself, simply pass | ||
# 'false' or omit the 'manage_repo' parameter--it defaults to 'false'. You will | ||
# still need to use the 'package_source_info' class to specify the postgres version | ||
# number, though, in order for the other classes to be able to find the | ||
# correct paths to the postgres dirs. | ||
|
||
class postgresql::package_source_info( | ||
$version, | ||
$manage_repo = false, | ||
$source = '' | ||
) { | ||
|
||
if ($manage_repo) { | ||
case $::osfamily { | ||
'RedHat': { | ||
if ! $source { | ||
$pkg_source = 'yum.postgresql.org' | ||
} else { | ||
$pkg_source = $source | ||
} | ||
|
||
case $pkg_source { | ||
'yum.postgresql.org': { | ||
class { "postgresql::package_source::yum_postgresql_org": | ||
version => $version | ||
} | ||
} | ||
|
||
default: { | ||
fail("Unsupported package source '${pkg_source}' for ${::osfamily} OS family. Currently the only supported source is 'yum.postgresql.org'") | ||
} | ||
} | ||
|
||
} | ||
|
||
default: { | ||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# puppet-postgresql | ||
# For all details and documentation: | ||
# http://github.com/inkling/puppet-postgresql | ||
# | ||
# Copyright 2012- Inkling Systems, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
class postgresql_tests::non_default::test_db($db) { | ||
|
||
class { "postgresql::package_source_info": | ||
version => '9.2', | ||
source => 'yum.postgresql.org', | ||
manage_repo => true, | ||
} -> | ||
|
||
class { "postgresql::server": } -> | ||
|
||
postgresql::db { $db: | ||
user => $db, | ||
password => $db, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
class postgresql_tests::non_default::test_install { | ||
|
||
file { '/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-92': | ||
source => 'puppet:///modules/postgresql_tests/RPM-GPG-KEY-PGDG-92' | ||
class { "postgresql::package_source_info": | ||
version => '9.2', | ||
source => 'yum.postgresql.org', | ||
manage_repo => true, | ||
} -> | ||
|
||
yumrepo { 'pgdg92': | ||
descr => 'PostgreSQL 9.2 $releasever - $basearch', | ||
baseurl => 'http://yum.postgresql.org/9.2/redhat/rhel-$releasever-$basearch', | ||
enabled => 1, | ||
gpgcheck => 1, | ||
gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-92', | ||
} -> | ||
|
||
class { "postgresql::server": | ||
package_name => 'postgresql92-server' | ||
} | ||
class { "postgresql::server": } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This manifest shows an example of how you can use a newer version of | ||
# postgres from yum.postgresql.org, rather than your system's | ||
# default version. | ||
# | ||
# Note that it is important that you use the '->', or a | ||
# before/require metaparameter to make sure that the `package_source_info` | ||
# class is evaluated before any of the other classes in the module. | ||
# | ||
# Also note that this example includes automatic management of the yumrepo | ||
# resource. If you'd prefer to manage the repo yourself, simply pass 'false' | ||
# or omit the 'manage_repo' parameter--it defaults to 'false'. You will still | ||
# need to use the 'package_source_info' class to specify the postgres version | ||
# number, though, in order for the other classes to be able to find the | ||
# correct paths to the postgres dirs. | ||
|
||
class { "postgresql::package_source_info": | ||
version => '9.2', | ||
source => 'yum.postgresql.org', | ||
manage_repo => true, | ||
} -> | ||
|
||
class { "postgresql::server": } |