Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Feature/master/support non default versions #43

Merged
merged 21 commits into from

2 participants

@cprice404
Owner

This is a slight refactor of #36. It adds support for versions of postgres other than the system default, and some initial framework for managing postgresql.org package repos. It also includes the first (extremely basic) spec tests for postgres 9.2 on CentOS6.

cprice404 and others added some commits
@cprice404 cprice404 A little more framework for CentOS pg9 testing 1b82be0
@etiennep etiennep Added easier support for Postgresql 9.0 (on RedHat platforms) 8e96959
@etiennep etiennep Pulled repository stuff out of params.
Lint cleanup.
a5d3de2
@etiennep etiennep Trying to overcome issues with stdlib version 5343c50
@etiennep etiennep Reverted back to 3.x version of stdlib 892ca0d
@etiennep etiennep More issues with stdlib dependencies. 50f9d3a
@etiennep etiennep Stdlib issues again. 2831906
@etiennep etiennep Stupid Librarian 1661ff1
@cprice404 cprice404 Fix paths b9a51be
@etiennep etiennep Refactored multi-version support. 1fe9559
@etiennep etiennep Removed repo class. ca701b3
@etiennep etiennep Removed references to $postgresql::paths in class params. db1a34e
@cprice404 cprice404 Fix paths 2a108ab
@etiennep etiennep Removed postgresql::version class and moved version info to init.pp. 33add5e
@etiennep etiennep Removed references to postgresql::paths in class params. d1025e9
@cprice404 cprice404 Working on getting ubuntu specs passing again
The service provider / status stuff got a little broken during
the refactors.  This should mostly fix it but there is still
one spec failing, and I will probably also refactor the
paths.pp and packages.pp into a single file together eventually.
90ed7aa
@cprice404 cprice404 Merge ::paths and ::packages into one class, called ::platform. de45945
@cprice404 cprice404 A few minor fixes to get tests passing again 663c779
@cprice404 cprice404 Re-add support for managing yumrepo
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.
fa24f24
@cprice404
Owner

@etiennep : would you be willing to test this out and see if it still covers your use cases? It's mostly your code, with a few minor changes:

  1. combined paths/packages into ::platform class... they seemed really similar and it seemed easier to keep that stuff all in one spot.
  2. introduced package_source_info class--has some simplistic stuff for managing the yumrepo (defaults to not managing it), and I am using it as the container for the version variable. This is kind of going back to your original idea of having a special "version" class to contain that... I really wanted to avoid the need for having any kind of container class that we had to reach into to grab a "global" variable from platform or elsewhere, but I tried a ton of different ideas and they were all looking like they were going to be worse. So I decided to basically go back to your original idea on that.
  3. there are vagrant spec tests for Cent6 now, including one that does some very basic stuff with postgres 9.2 on cent6.

If this looks like it'll suit your needs I'll probably merge it tomorrow-ish. Feel free to add comments or whatever if you have any thoughts!

@etiennep

I'm getting some merge conflicts with initdb.pp and database.pp btw.

@cprice404
Owner

Yeah, I don't recommend trying to merge this into your branch... I already had to deal with a bunch of merge conflicts from both sides. I'd recommend just pulling this branch directly if you can try it out.

@etiennep
@cprice404
Owner

@etiennep : so I just talked to a co-worker of mine and learned some interesting tricks that might clean this up a bit further (get rid of some of those repetitive "_real" blocks). I'll probably add a commit or two to this before I consider merging it now that I know these tricks :) But those commits should hopefully be cosmetic, so I'm still eager to hear whether or not this branch is working OK for your needs.

cprice404 added some commits
@cprice404 cprice404 Merge platform.pp back into params.pp
Nan showed me a trick that will let us keep all of that param stuff
inside of params.pp, make it a parameterized class, and still support
the ability for users to specify a custom (non-system-default) pg
version.  This commit takes the first step towards that pattern by
consolidating platform.pp and params.pp.  (Everything old is new again!)
18167c7
@cprice404 cprice404 Cleanup and move control of version into params
Thanks to some tricks I learned from Nan Liu and Dan Bode, I was
able to figure out a way to move all of the new version-related stuff
back into the params class, and clean up some of the if/_real stuff.

Basic tests for centos6 + pg 9.2 are passing.
228e5c5
@cprice404
Owner

@etiennep I think I'm basically done with this now, with the possible exception of adding some more docs. I just added a couple of commits that clean things up a lot, thanks to some secret sauce that my co-workers filled me in on. You can see an example of how to use it in tests/server-yum-postgresql-org.pp. I'd love to get this merged today or tomorrow but since you are responsible for a lot of this work, I definitely want to make sure it meets your needs first!

@cprice404 cprice404 merged commit 9d12358 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 3, 2012
  1. @cprice404
  2. @etiennep @cprice404
  3. @etiennep @cprice404

    Pulled repository stuff out of params.

    etiennep authored cprice404 committed
    Lint cleanup.
  4. @etiennep @cprice404

    Trying to overcome issues with stdlib version

    etiennep authored cprice404 committed
  5. @etiennep @cprice404

    Reverted back to 3.x version of stdlib

    etiennep authored cprice404 committed
  6. @etiennep @cprice404

    More issues with stdlib dependencies.

    etiennep authored cprice404 committed
  7. @etiennep @cprice404

    Stdlib issues again.

    etiennep authored cprice404 committed
  8. @etiennep @cprice404

    Stupid Librarian

    etiennep authored cprice404 committed
  9. @cprice404

    Fix paths

    cprice404 authored
  10. @etiennep @cprice404

    Refactored multi-version support.

    etiennep authored cprice404 committed
  11. @etiennep @cprice404

    Removed repo class.

    etiennep authored cprice404 committed
  12. @etiennep @cprice404
  13. @cprice404

    Fix paths

    cprice404 authored
  14. @etiennep @cprice404
  15. @etiennep @cprice404
  16. @cprice404

    Working on getting ubuntu specs passing again

    cprice404 authored
    The service provider / status stuff got a little broken during
    the refactors.  This should mostly fix it but there is still
    one spec failing, and I will probably also refactor the
    paths.pp and packages.pp into a single file together eventually.
  17. @cprice404
  18. @cprice404
  19. @cprice404

    Re-add support for managing yumrepo

    cprice404 authored
    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.
Commits on Dec 4, 2012
  1. @cprice404

    Merge platform.pp back into params.pp

    cprice404 authored
    Nan showed me a trick that will let us keep all of that param stuff
    inside of params.pp, make it a parameterized class, and still support
    the ability for users to specify a custom (non-system-default) pg
    version.  This commit takes the first step towards that pattern by
    consolidating platform.pp and params.pp.  (Everything old is new again!)
  2. @cprice404

    Cleanup and move control of version into params

    cprice404 authored
    Thanks to some tricks I learned from Nan Liu and Dan Bode, I was
    able to figure out a way to move all of the new version-related stuff
    back into the params class, and clean up some of the if/_real stuff.
    
    Basic tests for centos6 + pg 9.2 are passing.
This page is out of date. Refresh to see the latest.
Showing with 302 additions and 97 deletions.
  1. +1 −1  Modulefile
  2. +4 −0 Rakefile
  3. +20 −20 manifests/config.pp
  4. +3 −2 manifests/config/beforeservice.pp
  5. +1 −1  manifests/database.pp
  6. +2 −3 manifests/devel.pp
  7. +9 −3 manifests/init.pp
  8. +1 −2  manifests/initdb.pp
  9. +22 −0 manifests/package_source/yum_postgresql_org.pp
  10. +89 −28 manifests/params.pp
  11. +1 −1  manifests/psql.pp
  12. +24 −16 manifests/server.pp
  13. +4 −12 manifests/validate_db_connection.pp
  14. +3 −3 spec/support/postgres_test_config.rb
  15. +1 −1  spec/support/shared_contexts/pg_vm_context.rb
  16. +20 −3 spec/support/shared_examples/non_default_postgres.rb
  17. +1 −1  spec/support/vagrant_common.rb
  18. +30 −0 spec/test_module/files/RPM-GPG-KEY-PGDG-92
  19. +33 −0 spec/test_module/manifests/non_default/test_db.pp
  20. +10 −0 spec/test_module/manifests/non_default/test_install.pp
  21. 0  spec/{ → test_module}/manifests/system_default/test_db.pp
  22. 0  spec/{ → test_module}/manifests/system_default/test_grant_create.pp
  23. 0  spec/{ → test_module}/manifests/system_default/test_initdb.pp
  24. 0  spec/{ → test_module}/manifests/system_default/test_psql.pp
  25. 0  spec/{ → test_module}/manifests/system_default/test_ruby_psql.pp
  26. 0  spec/{ → test_module}/manifests/system_default/test_user.pp
  27. +23 −0 tests/server-yum-postgresql-org.pp
View
2  Modulefile
@@ -7,5 +7,5 @@ summary 'PostgreSQL defined resource types'
license 'Apache'
project_page 'https://github.com/puppetlabs/puppet-postgresql/issues'
-dependency 'puppetlabs/stdlib', '3.x'
+dependency 'puppetlabs/stdlib', '>= 3.2.0'
dependency 'puppetlabs/firewall', '>= 0.0.4'
View
4 Rakefile
@@ -0,0 +1,4 @@
+#require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint/tasks/puppet-lint'
+
+PuppetLint.configuration.send("disable_80chars")
View
40 manifests/config.pp
@@ -44,29 +44,29 @@
$manage_redhat_firewall = $postgresql::params::manage_redhat_firewall
) inherits postgresql::params {
- # Basically, all this class needs to handle is passing parameters on
- # to the "beforeservice" and "afterservice" classes, and ensure
- # the proper ordering.
+ # Basically, all this class needs to handle is passing parameters on
+ # to the "beforeservice" and "afterservice" classes, and ensure
+ # the proper ordering.
- class { 'postgresql::config::beforeservice':
- ip_mask_deny_postgres_user => $ip_mask_deny_postgres_user,
- ip_mask_allow_all_users => $ip_mask_allow_all_users,
- listen_addresses => $listen_addresses,
- ipv4acls => $ipv4acls,
- ipv6acls => $ipv6acls,
- pg_hba_conf_path => $pg_hba_conf_path,
- postgresql_conf_path => $postgresql_conf_path,
- manage_redhat_firewall => $manage_redhat_firewall,
- }
+ class { 'postgresql::config::beforeservice':
+ ip_mask_deny_postgres_user => $ip_mask_deny_postgres_user,
+ ip_mask_allow_all_users => $ip_mask_allow_all_users,
+ listen_addresses => $listen_addresses,
+ ipv4acls => $ipv4acls,
+ ipv6acls => $ipv6acls,
+ pg_hba_conf_path => $pg_hba_conf_path,
+ postgresql_conf_path => $postgresql_conf_path,
+ manage_redhat_firewall => $manage_redhat_firewall,
+ }
- class { 'postgresql::config::afterservice':
- postgres_password => $postgres_password,
- }
+ class { 'postgresql::config::afterservice':
+ postgres_password => $postgres_password,
+ }
- Class['postgresql::config'] ->
- Class['postgresql::config::beforeservice'] ->
- Service['postgresqld'] ->
- Class['postgresql::config::afterservice']
+ Class['postgresql::config'] ->
+ Class['postgresql::config::beforeservice'] ->
+ Service['postgresqld'] ->
+ Class['postgresql::config::afterservice']
}
View
5 manifests/config/beforeservice.pp
@@ -34,16 +34,17 @@
# }
#
class postgresql::config::beforeservice(
+ $pg_hba_conf_path,
+ $postgresql_conf_path,
$ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
$ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users,
$listen_addresses = $postgresql::params::listen_addresses,
$ipv4acls = $postgresql::params::ipv4acls,
$ipv6acls = $postgresql::params::ipv6acls,
- $pg_hba_conf_path = $postgresql::params::pg_hba_conf_path,
- $postgresql_conf_path = $postgresql::params::postgresql_conf_path,
$manage_redhat_firewall = $postgresql::params::manage_redhat_firewall
) inherits postgresql::params {
+
File {
owner => $postgresql::params::user,
group => $postgresql::params::group,
View
2  manifests/database.pp
@@ -23,7 +23,7 @@
$dbname = $title,
$charset = 'UTF8')
{
- require postgresql::params
+ include postgresql::params
if ($::postgres_default_version != '8.1') {
$locale_option = '--locale=C'
View
5 manifests/devel.pp
@@ -17,10 +17,9 @@
$package_ensure = 'present'
) inherits postgresql::params {
- require postgresql
-
- package { 'postgresql_devel':
+ package { 'postgresql-devel':
ensure => $package_ensure,
name => $package_name,
+ tag => 'postgresql',
}
}
View
12 manifests/init.pp
@@ -2,9 +2,13 @@
#
# This class installs postgresql client software.
#
-# Parameters:
-# [*client_package_name*] - The name of the postgresql client package.
+# *Note* don't forget to make sure to add any necessary yum or apt
+# repositories if specifying a custom version.
#
+# Parameters:
+# [*version*] - The postgresql version to install.
+# [*package_name*] - The name of the postgresql client package.
+# [*ensure*] - the ensure parameter passed to the postgresql client package resource
# Actions:
#
# Requires:
@@ -12,13 +16,15 @@
# Sample Usage:
#
class postgresql (
+ $version = $::postgres_default_version,
$package_name = $postgresql::params::client_package_name,
$package_ensure = 'present'
) inherits postgresql::params {
- package { 'postgresql_client':
+ package { 'postgresql-client':
ensure => $package_ensure,
name => $package_name,
+ tag => 'postgresql',
}
}
View
3  manifests/initdb.pp
@@ -21,12 +21,11 @@
$encoding = 'UTF8',
$group = 'postgres',
$initdb_path = $postgresql::params::initdb_path,
- $options = '',
$user = 'postgres'
) inherits postgresql::params {
$initdb_command = "${initdb_path} --encoding '${encoding}' --pgdata '${datadir}'"
-
+
exec { $initdb_command:
creates => "${datadir}/PG_VERSION",
user => $user,
View
22 manifests/package_source/yum_postgresql_org.pp
@@ -0,0 +1,22 @@
+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}",
+ }
+
+ Yumrepo["yum.postgresql.org"] -> Package<|tag == 'postgresql'|>
+
+}
View
117 manifests/params.pp
@@ -10,7 +10,28 @@
#
# Sample Usage:
#
-class postgresql::params {
+
+# TODO: add real docs
+
+# This class allows you to use a newer version of postgres, rather than your
+# system's default version.
+#
+# If you want to do that, note that it is important that you use the '->',
+# or a before/require metaparameter to make sure that the `params`
+# 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 'params' 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::params(
+ $version = $::postgres_default_version,
+ $manage_package_repo = false,
+ $package_source = undef,
+) {
$user = 'postgres'
$group = 'postgres'
$ip_mask_deny_postgres_user = '0.0.0.0/0'
@@ -21,6 +42,32 @@
# TODO: figure out a way to make this not platform-specific
$manage_redhat_firewall = false
+
+ if ($manage_package_repo) {
+ case $::osfamily {
+ 'RedHat': {
+ $rh_pkg_source = pick($package_source, 'yum.postgresql.org')
+
+ case $rh_pkg_source {
+ 'yum.postgresql.org': {
+ class { "postgresql::package_source::yum_postgresql_org":
+ version => $version
+ }
+ }
+
+ default: {
+ fail("Unsupported package source '${rh_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 is a bit hacky, but if the puppet nodes don't have pluginsync enabled,
# they will fail with a not-so-helpful error message. Here we are explicitly
# verifying that the custom fact exists (which implies that pluginsync is
@@ -39,25 +86,43 @@
case $::osfamily {
'RedHat': {
- $service_name = 'postgresql'
- $client_package_name = 'postgresql'
- $server_package_name = 'postgresql-server'
- $devel_package_name = 'postgresql-devel'
$needs_initdb = true
- $initdb_path = '/usr/bin/initdb'
- $createdb_path = '/usr/bin/createdb'
- $psql_path = '/usr/bin/psql'
- $datadir = '/var/lib/pgsql/data/'
- $pg_hba_conf_path = '/var/lib/pgsql/data/pg_hba.conf'
- $postgresql_conf_path = '/var/lib/pgsql/data/postgresql.conf'
$firewall_supported = true
$persist_firewall_command = '/sbin/iptables-save > /etc/sysconfig/iptables'
+
+ if $version == $::postgres_default_version {
+ $client_package_name = 'postgresql'
+ $server_package_name = 'postgresql-server'
+ $devel_package_name = 'postgresql-devel'
+ $service_name = 'postgresql'
+ $bindir = '/usr/bin'
+ $datadir = '/var/lib/pgsql/data'
+ $confdir = $datadir
+ } else {
+ $version_parts = split($version, '[.]')
+ $package_version = "${version_parts[0]}${version_parts[1]}"
+ $client_package_name = "postgresql${package_version}"
+ $server_package_name = "postgresql${package_version}-server"
+ $devel_package_name = "postgresql${package_version}-devel"
+ $service_name = "postgresql-${version}"
+ $bindir = "/usr/pgsql-${version}/bin"
+ $datadir = "/var/lib/pgsql/${version}/data"
+ $confdir = $datadir
+ }
+
+ $service_status = undef
}
'Debian': {
+ $needs_initdb = false
+ $firewall_supported = false
+ # TODO: not exactly sure yet what the right thing to do for Debian/Ubuntu is.
+ #$persist_firewall_command = '/sbin/iptables-save > /etc/iptables/rules.v4'
+
+
case $::operatingsystem {
'Debian': {
- $service_name = 'postgresql'
+ $service_name = 'postgresql'
}
'Ubuntu': {
@@ -69,27 +134,23 @@
}
}
- $client_package_name = 'postgresql-client'
- $server_package_name = 'postgresql'
- $devel_package_name = 'libpq-dev'
- $needs_initdb = false
- $initdb_path = "/usr/lib/postgresql/${::postgres_default_version}/bin/initdb"
- $createdb_path = "/usr/lib/postgresql/${::postgres_default_version}/bin/createdb"
- $psql_path = "/usr/lib/postgresql/${::postgres_default_version}/bin/psql"
- $datadir = "/var/lib/postgresql/${::postgres_default_version}/main"
- $pg_hba_conf_path = "/etc/postgresql/${::postgres_default_version}/main/pg_hba.conf"
- $postgresql_conf_path = "/etc/postgresql/${::postgres_default_version}/main/postgresql.conf"
- $firewall_supported = false
- $service_status = "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+'"
- # TODO: not exactly sure yet what the right thing to do for Debian/Ubuntu is.
- #$persist_firewall_command = '/sbin/iptables-save > /etc/iptables/rules.v4'
-
+ $client_package_name = 'postgresql-client'
+ $server_package_name = 'postgresql'
+ $devel_package_name = 'libpq-dev'
+ $bindir = "/usr/lib/postgresql/${::postgres_default_version}/bin"
+ $datadir = "/var/lib/postgresql/${::postgres_default_version}/main"
+ $confdir = "/etc/postgresql/${::postgres_default_version}/main"
+ $service_status = "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+'"
}
-
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian")
}
}
+ $initdb_path = "${bindir}/initdb"
+ $createdb_path = "${bindir}/createdb"
+ $psql_path = "${bindir}/psql"
+ $pg_hba_conf_path = "${confdir}/pg_hba.conf"
+ $postgresql_conf_path = "${confdir}/postgresql.conf"
}
View
2  manifests/psql.pp
@@ -24,7 +24,7 @@
$user = 'postgres'
) {
- require postgresql::params
+ include postgresql::params
# TODO: FIXME: shellquote does not work, and this regex works for trivial
# things but not nested escaping. Need a lexer, preferably a ruby SQL parser
View
40 manifests/server.pp
@@ -1,10 +1,12 @@
# Class: postgresql::server
#
-# manages the installation of the postgresql server. manages the package and service
+# == Class: postgresql::server
+# Manages the installation of the postgresql server. manages the package and
+# service.
#
-# Parameters:
-# [*package_name*] - name of package
-# [*service_name*] - name of service
+# === Parameters:
+# [*package_name*] - name of package
+# [*service_name*] - name of service
#
# Actions:
#
@@ -22,23 +24,16 @@
) inherits postgresql::params {
package { 'postgresql-server':
- ensure => $package_ensure,
- name => $package_name,
+ ensure => $package_ensure,
+ name => $package_name,
+ tag => 'postgresql',
}
$config_class = {}
$config_class['postgresql::config'] = $config_hash
create_resources( 'class', $config_class )
-
- Package['postgresql-server'] -> Class['postgresql::config']
-
- if ($needs_initdb) {
- include postgresql::initdb
-
- Class['postgresql::initdb'] -> Class['postgresql::config']
- Class['postgresql::initdb'] -> Service['postgresqld']
- }
+
service { 'postgresqld':
ensure => running,
@@ -49,9 +44,22 @@
status => $service_status,
}
+ if ($postgresql::params::needs_initdb) {
+ include postgresql::initdb
+
+ Package['postgresql-server'] -> Class['postgresql::initdb'] -> Class['postgresql::config'] -> Service['postgresqld']
+ }
+ else {
+ Package['postgresql-server'] -> Class['postgresql::config'] -> Service['postgresqld']
+ }
+
exec { 'reload_postgresql':
path => '/usr/bin:/usr/sbin:/bin:/sbin',
- command => "service ${postgresql::params::service_name} reload",
+ command => "service ${service_name} reload",
+ user => $postgresql::params::user,
+ group => $postgresql::params::group,
+ onlyif => $service_status,
refreshonly => true,
}
+
}
View
16 manifests/validate_db_connection.pp
@@ -49,24 +49,16 @@
$database_name,
$database_password,
$database_username,
- $client_package_name = '',
+ $client_package_name = $postgresql::params::client_package_name,
$database_port = 5432
-) {
- include postgresql::params
-
- # This is a bit messy, but we need to use the correct client package name
- # from the params class if the user did not explicitly provide one.
- if (! $client_package_name) {
- $package_name = $postgresql::params::client_package_name
- } else {
- $package_name = $client_package_name
- }
+) inherits postgresql::params {
# Make sure the postgres client package is installed; we need it for
# `psql`.
package { 'postgresql-client':
ensure => present,
- name => $package_name,
+ name => $client_package_name,
+ tag => 'postgresql',
}
# TODO: port to ruby
View
6 spec/support/postgres_test_config.rb
@@ -4,11 +4,11 @@ module PostgresTestConfig
# valuable for final testing. This constant allows you to toggle between
# strict testing and less strict testing--the latter being useful for
# development purposes.
- HardCoreTesting = false
+ HardCoreTesting = true
# If this value is set to true, then each VM will be suspended after the tests
# against it are completed. This will slow things down a ton during
# iterative development, but will save a lot of system resources by not
# keeping all of the VMs running at the same time.
- SuspendVMsAfterSuite = false
-end
+ SuspendVMsAfterSuite = true
+end
View
2  spec/support/shared_contexts/pg_vm_context.rb
@@ -23,7 +23,7 @@
@env.cli("up", vm.to_s)
if PostgresTestConfig::HardCoreTesting
- sudo_and_log(vm, '[ "$(facter osfamily)" == "Debian" ] && apt-get update')
+ sudo_and_log(vm, 'if [ "$(facter osfamily)" == "Debian" ] ; then apt-get update ; fi')
end
install_postgres
View
23 spec/support/shared_examples/non_default_postgres.rb
@@ -7,10 +7,27 @@
# this method is required by the pg_vm shared context
def install_postgres
- #sudo_and_log(vm, 'puppet apply -e "include postgresql::server"')
- # TODO: implement
+ sudo_and_log(vm, 'puppet apply -e "include postgresql_tests::non_default::test_install"')
end
- it "doesn't have any tests yet'" do
+ describe 'postgresql::db' do
+ it 'should idempotently create a db that we can connect to' do
+
+ # A bare-minimum class to add a DB to postgres, which will be running due to ubuntu
+ test_class = 'class {"postgresql_tests::non_default::test_db": db => "postgresql_test_db" }'
+
+ begin
+ # Run once to check for crashes
+ sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{test_class}'; [ $? == 2 ]")
+
+ # Run again to check for idempotence
+ sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{test_class}'")
+
+ # Check that the database name is present
+ sudo_psql_and_log(vm, 'postgresql_test_db --command="select datname from pg_database limit 1"')
+ ensure
+ sudo_psql_and_log(vm, '--command="drop database postgresql_test_db" postgres')
+ end
+ end
end
end
View
2  spec/support/vagrant_common.rb
@@ -11,7 +11,7 @@ def apply_common_vagrant_config(config)
config.vm.share_folder "puppet-postgresql-module", "/usr/share/puppet/modules/postgresql", "../../.."
# Share the module of test classes
- config.vm.share_folder "puppet-postgresql-tests", "/usr/share/puppet/modules/postgresql_tests", "../.."
+ config.vm.share_folder "puppet-postgresql-tests", "/usr/share/puppet/modules/postgresql_tests", "../../test_module"
# Provision with a base puppet config just so we don't have to repeat the puppet user/group
config.vm.provision :puppet do |puppet|
View
30 spec/test_module/files/RPM-GPG-KEY-PGDG-92
@@ -0,0 +1,30 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1.4.7 (GNU/Linux)
+
+mQGiBEeD8koRBACC1VBRsUwGr9gxFFRho9kZpdRUjBJoPhkeOTvp9LzkdAQMFngr
+BFi6N0ov1kCX7LLwBmDG+JPR7N+XcH9YR1coSHpLVg+JNy2kFDd4zAyWxJafjZ3a
+9zFg9Yx+0va1BJ2t4zVcmKS4aOfbgQ5KwIOWUujalQW5Y+Fw39Gn86qjbwCg5dIo
+tkM0l19h2sx50D027pV5aPsD/2c9pfcFTbMhB0CcKS836GH1qY+NCAdUwPs646ee
+Ex/k9Uy4qMwhl3HuCGGGa+N6Plyon7V0TzZuRGp/1742dE8IO+I/KLy2L1d1Fxrn
+XOTBZd8qe6nBwh12OMcKrsPBVBxn+iSkaG3ULsgOtx+HHLfa1/p22L5+GzGdxizr
+peBuA/90cCp+lYcEwdYaRoFVR501yDOTmmzBc1DrsyWP79QMEGzMqa393G0VnqXt
+L4pGmunq66Agw2EhPcIt3pDYiCmEt/obdVtSJH6BtmSDB/zYhbE8u3vLP3jfFDa9
+KXxgtYj0NvuUVoRmxSKm8jtfmj1L7zoKNz3jl+Ba3L0WxIv4+bRBUG9zdGdyZVNR
+TCBSUE0gQnVpbGRpbmcgUHJvamVjdCA8cGdzcWxycG1zLWhhY2tlcnNAcGdmb3Vu
+ZHJ5Lm9yZz6IYAQTEQIAIAUCR4PySgIbIwYLCQgHAwIEFQIIAwQWAgMBAh4BAheA
+AAoJEB8W0uFELfD4jnkAoMqd6ZwwsgYHZ3hP9vt+DJt1uDW7AKDbRwP8ESKFhwdJ
+8m91RPBeJW/tMLkCDQRHg/JKEAgA64+ZXgcERPYfZYo4p+yMTJAAa9aqnE3U4Ni6
+ZMB57GPuEy8NfbNya+HiftO8hoozmJdcI6XFyRBCDUVCdZ8SE+PJdOx2FFqZVIu6
+dKnr8ykhgLpNNEFDG3boK9UfLj/5lYQ3Y550Iym1QKOgyrJYeAp6sZ+Nx2PavsP3
+nMFCSD67BqAbcLCVQN7a2dAUXfEbfXJjPHXTbo1/kxtzE+KCRTLdXEbSEe3nHO04
+K/EgTBjeBUOxnciH5RylJ2oGy/v4xr9ed7R1jJtshsDKMdWApwoLlCBJ63jg/4T/
+z/OtXmu4AvmWaJxaTl7fPf2GqSqqb6jLCrQAH7AIhXr9V0zPZwADBQgAlpptNQHl
+u7euIdIujFwwcxyQGfee6BG+3zaNSEHMVQMuc6bxuvYmgM9r7aki/b0YMfjJBk8v
+OJ3Eh1vDH/woJi2iJ13vQ21ot+1JP3fMd6NPR8/qEeDnmVXu7QAtlkmSKI9Rdnjz
+FFSUJrQPHnKsH4V4uvAM+njwYD+VFiwlBPTKNeL8cdBb4tPN2cdVJzoAp57wkZAN
+VA2tKxNsTJKBi8wukaLWX8+yPHiWCNWItvyB4WCEp/rZKG4A868NM5sZQMAabpLd
+l4fTiGu68OYgK9qUPZvhEAL2C1jPDVHPkLm+ZsD+90Pe66w9vB00cxXuHLzm8Pad
+GaCXCY8h3xi6VIhJBBgRAgAJBQJHg/JKAhsMAAoJEB8W0uFELfD4K4cAoJ4yug8y
+1U0cZEiF5W25HDzMTtaDAKCaM1m3Cbd+AZ0NGWNg/VvIX9MsPA==
+=au6K
+-----END PGP PUBLIC KEY BLOCK-----
View
33 spec/test_module/manifests/non_default/test_db.pp
@@ -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::params":
+ version => '9.2',
+ manage_package_repo => true,
+ package_source => 'yum.postgresql.org',
+ } ->
+
+ class { "postgresql::server": } ->
+
+ postgresql::db { $db:
+ user => $db,
+ password => $db,
+ }
+}
View
10 spec/test_module/manifests/non_default/test_install.pp
@@ -0,0 +1,10 @@
+class postgresql_tests::non_default::test_install {
+
+ class { "postgresql::params":
+ version => '9.2',
+ manage_package_repo => true,
+ package_source => 'yum.postgresql.org',
+ } ->
+
+ class { "postgresql::server": }
+}
View
0  spec/manifests/system_default/test_db.pp → spec/test_module/manifests/system_default/test_db.pp
File renamed without changes
View
0  spec/manifests/system_default/test_grant_create.pp → ...ule/manifests/system_default/test_grant_create.pp
File renamed without changes
View
0  spec/manifests/system_default/test_initdb.pp → ...st_module/manifests/system_default/test_initdb.pp
File renamed without changes
View
0  spec/manifests/system_default/test_psql.pp → ...test_module/manifests/system_default/test_psql.pp
File renamed without changes
View
0  spec/manifests/system_default/test_ruby_psql.pp → ...module/manifests/system_default/test_ruby_psql.pp
File renamed without changes
View
0  spec/manifests/system_default/test_user.pp → ...test_module/manifests/system_default/test_user.pp
File renamed without changes
View
23 tests/server-yum-postgresql-org.pp
@@ -0,0 +1,23 @@
+# 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 `params`
+# 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 'params' 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::params":
+ version => '9.2',
+ manage_package_repo => true,
+ package_source => 'yum.postgresql.org',
+} ->
+
+class { "postgresql::server": }
Something went wrong with that request. Please try again.