From 1d83efbcecaf5f6a215fd0610da02f1503f90892 Mon Sep 17 00:00:00 2001 From: Karel Brezina Date: Wed, 13 Feb 2013 12:14:53 +0100 Subject: [PATCH] Database name, user name and password can be set to arbitrary values. --- manifests/database/postgresql.pp | 27 ++++++++++++++++++--------- manifests/init.pp | 5 ++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/manifests/database/postgresql.pp b/manifests/database/postgresql.pp index 0863d5a..434a418 100644 --- a/manifests/database/postgresql.pp +++ b/manifests/database/postgresql.pp @@ -13,12 +13,18 @@ # be compatible with puppetdb. # # Parameters: -# ['listen_addresses'] - A comma-separated list of hostnames or IP addresses -# on which the postgres server should listen for incoming -# connections. (Defaults to 'localhost'. This parameter -# maps directly to postgresql's 'listen_addresses' config -# option; use a '*' to allow connections on any accessible -# address. +# ['listen_addresses'] - A comma-separated list of hostnames or IP addresses +# on which the postgres server should listen for incoming +# connections. (Defaults to 'localhost'. This parameter +# maps directly to postgresql's 'listen_addresses' config +# option; use a '*' to allow connections on any accessible +# address. +# ['database_name'] - The name of the database instance to connect to. +# (defaults to `puppetdb`) +# ['database_username'] - The name of the database user to connect as. +# (defaults to `puppetdb`) +# ['database_password'] - The password for the database user. +# (defaults to `puppetdb`) # Actions: # - Creates and manages a postgres server and database instance for use by # puppetdb @@ -35,6 +41,9 @@ class puppetdb::database::postgresql( # TODO: expose more of the parameters from `inkling/postgresql`! $listen_addresses = $puppetdb::params::database_host, $manage_redhat_firewall = $puppetdb::params::open_postgres_port, + $database_name = $puppetdb::params::database_name, + $database_username = $puppetdb::params::database_username, + $database_password = $puppetdb::params::database_password, ) inherits puppetdb::params { # This technically defaults to 'true', but in order to preserve backwards @@ -61,9 +70,9 @@ class puppetdb::database::postgresql( } # create the puppetdb database - postgresql::db{ 'puppetdb': - user => 'puppetdb', - password => 'puppetdb', + postgresql::db{ $database_name: + user => $database_username, + password => $database_password, grant => 'all', require => Class['::postgresql::server'], } diff --git a/manifests/init.pp b/manifests/init.pp index 3ab1207..34c12ac 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -121,7 +121,10 @@ class puppetdb( false => $manage_redhat_firewall, undef => $open_postgres_port, }, - listen_addresses => $postgres_listen_addresses, + listen_addresses => $puppetdb::params::postgres_listen_addresses, + database_name => $database_name, + database_username => $database_username, + database_password => $database_password, before => Class['puppetdb::server'] } }