Commit graph

26 commits

Author SHA1 Message Date
Ken Barber
59c1cbfbf8 Major rewrite to solve order dependencies and unclear public API
This is a very very large change to the module. It started out as a fix to add
postgresl::server::config_entry, and quickly became a rewrite to fix a lot of
ordering issues inherent in the API.

Since this changes the Public API it is considered a backwards compatible
change.

See the upgrading guide in README.md for more details as to what has been
modified in this patch.

Signed-off-by: Ken Barber <ken@bob.sh>
2013-09-14 06:39:15 +01:00
Rahul Gopinath
1dce6454c8 Pulling in pgconf module from camptocamp/puppet-pgconf
This includes the following changes:
  - Hooking up pgconf module to postgresql to manage postgresql.conf
   - pgconf includes a type and provider for postgresql.conf the provider
     is a simple parsed file following basic ini parsing.
  - Add config_entry.pp which wraps the pgconf module.
  - Replace file_line resources by postgresql::config_entry in beforeservice.pp
  - Adding unit tests for the newly introduced functionality
2013-09-14 06:38:53 +01:00
Hunter Haugen
8919359bca Use boolean for refreshonly
Puppet::Type supports `:boolean => true` to create a
`resource.<property>?` method that is true or false based on the
`:true`, `:false`, `true`, or `false` value of the parameter.

This will allow accurate assesment of the refreshonly attribute for
testing.
2013-08-13 16:18:02 -07:00
fiddyspence
2eb03efc29 Alter escaping in postgresql::config::afterservice
This allows non-standard users (pe-postgres) to change passwords. Also
added a function to do escaping of the password, added system tests
and rspec tests for the function.
2013-07-23 13:04:46 +01:00
Ken Barber
7a11366631 Merge pull request #151 from antaflos/psql_cwd
Set /tmp as default CWD for postgresql_psql
2013-04-29 11:52:29 -07:00
Kamil Szymanski
10aca2ce2f Add default PostgreSQL version for Ubuntu 13.04 2013-04-18 23:11:40 +02:00
Dominic Cleal
afa63ef850 Pass only arrays to Puppet::Util.execute() for Puppet 2.6 compatibility 2013-03-21 18:13:13 +00:00
Andreas Ntaflos
5f7087e68c Set /tmp as default CWD for postgresql_psql
This has been discussed in issue #148. The postgresql_psql type doesn't
change the CWD to something safe when running psql as the postgres user.
During a regular puppet run the CWD remains "/root", to which the
postgres user usually does not have access, resulting in failed psql
calls and failed puppet runs. This simple change makes "/tmp" the
default CWD for postgresql_psql.
2013-03-08 19:24:52 +01:00
Kamil Szymanski
b46763d4a7 Update postgres_default_version for Ubuntu 2013-02-28 16:04:43 +01:00
Ken Barber
501289394a Cleaned up and added unit tests
Signed-off-by: Ken Barber <ken@bob.sh>
2013-02-25 17:50:53 +00:00
Karel Brezina
5ef164b1a6 Generalization to provide more flexibility in postgresql configuration 2013-02-25 17:50:34 +00:00
Carlos Villela
6f6da927d1 Allow SQL commands to be run against a specific DB
If resource[:db] is set, then it is sent to psql. 

Otherwise, argument is omitted and should not introduce any regression.
2013-02-24 02:50:26 -03:00
Ken Barber
86a0453f2f Provide new defined resources for managing pg_hba.conf
This patch provides a more advanced way of managing pg_hba rules, by providing a
defined resource to manage a pg_hba file, and a defined resource for managing
rules within such a file (pg_hba_rule).

These new resources are wrappers around ripinaar-concat, and utilise file
assemblies instead of a template to compose the pg_hba.conf file.

I've provided a function that interprets the old ip4|6acl arrays and converts
them to this new format for backwards compatibility as well.

I slightly reformatted our documentation to allow for better documentation of
defined resources in 'Usage' as well, and provided examples of how to use this
new resource.

This hopefully should go a long way to solving the PR's related to lack of full
functionality for pg_hba.conf.

Signed-off-by: Ken Barber <ken@bob.sh>
2013-02-12 00:34:42 +00:00
Ken Barber
e9370fee7b Add unit tests and travis-ci support
This patch includes some very basic and initial unit testing using rspec-puppet
and for the case of facts, just normal rspec.

I've taken a very light approach here as rspec-puppet can be quite combinatorial
when one gets carried away. For now I've just added basic compile failure
detection effectively for classes and defined resources. As we continue to work
on the code and find regressions this work can be expanded.

For facts and functions I've also taken a basic approach for now.

One little thing I did change, was the strange string that the fact returns
when the default version is undefined. Instead of an error message I've just
returned the string 'unknown' which is more in line with other facts I've seen
in the wild, and to be quite honest 'unknown' is fairly self-explantory. Since
a fact isn't an error reporting message this seemed more appropriate, and looked
nicer in the rspec test.

As far as travis-ci support, I've added the same configuration that @jmmcune
came up with for stdlib which is pretty light and reasonable standard now we
propogated that to 4 or so other modules in the puppetlabs/ namespace. It should
work out of the box.

Signed-off-by: Ken Barber <ken@bob.sh>
2013-02-05 15:15:03 +00:00
Chris Price
5e47aff57a Merge pull request #94 from puppetlabs-operations/wheezy_7_0_default_version
Update postgres_default_version to 9.1 for debian 7.0
2013-01-23 09:02:49 -08:00
Adrien Thebo
04a7b06d15 Update postgres_default_version to 9.1 for debian 7.0
/etc/debian_version on Wheezy was updated to 7.0 with the release of the
base-files package on 2012-12-12, which means that wheezy could be
either 7.0 or wheezy depending on what version of base-files is
installed. To handle both cases we treat 'wheezy' and '7.*' as
synonymous.
2013-01-22 20:54:19 -08:00
Chris Price
dfa397c26e Fix error message in default version fact
A commit that I merged yesterday broke the default version fact
such that it would sometimes return nil and sometimes an error message
if your distro wasn't supported.  This commit makes it consistent again.
2013-01-15 13:25:21 -08:00
Henrik
02aef86e31 updating the switch statement looking at osfamily 2013-01-14 22:35:25 +01:00
Jordi Boggiano
82dc194a7d Provide version for ubuntu 12.10 2013-01-14 19:48:52 +01:00
Adrien Thebo
147fa8e59b Add Debian wheezy support for default version fact
Debian Wheezy has a default version of 9.1, but doesn't currently have
an operatingsystemrelease value beyond 'wheezy'. This command searches
for wheezy in the operatingsystemrelease fact and sets the fact value
accordingly.
2013-01-07 19:02:34 -08:00
Brett Porter
6b53c07da0 set an appropriate parent for the parameter 2012-12-14 23:22:38 +11:00
Brett Porter
6367e359ea add optional cwd to the postgres_psql command
When the psql command runs from a directory it does not have permission to
access, it outputs an error. This error trips up the unless SQL command,
causing the other SQL commands to run even if not needed. Rather than ignore
stderr (which might hide something else), or use an arbitrary directory like
/tmp, this code sets the cwd to the data directory, which will exist and be
owned by the postgres user. If someone uses the postgres_psql type and
customises the psql_user parameter, they should also set an appropriate cwd.
2012-12-14 23:02:18 +11:00
Chris Price
208b663ad1 Rework postgres_default_version fact
This commit fixes up the `postgres_default_version` fact so that
it doesn't use apt/yum (slow), and instead just has a hard-coded
list of default postgres versions for various OS versions.  We
will need to add new OS versions to this fact over time, but that
seems preferable to the previous implementation which was causing
slower puppet runs on all nodes (regardless of whether they were
actually using postgres or not).
2012-12-07 10:40:18 -08:00
Chris Price
2a922f104a Initial working implementation of ruby psql type/provider
This commit provides a working implementation of a ruby
type/provider (`postgresql_psql` for handling the PSQL
commands.  This is a little more flexible than doing it
via Exec resources, which is what the `postgresql::psql`
type was doing.

The old type is still present but now includes a
deprecation notification, and all of the other types
that were using the `::psql` type have been ported over
to use the `postgresql_psql` type instead.
2012-11-04 21:47:49 -08:00
Chris Price
45055d324c Bring database, database_user, and database_grant into alignment with mysql module
Renamed a few files and made some tweaks to try to get
database_grant, database_user, and database types into
a state where they work very similarly to the ones in
the mysql module.  Also introduced a "postgresql_password"
function that can be used to generate an md5 password
hash for a postgres user.
2012-06-08 22:30:27 -07:00
Chris Price
6034e122de Working version of postgresql::server
This is a first working version of postgresql::server.
It includes a very simple test manifest, which has
been tried out on CentOS6 and Ubuntu 10.04; initial
tests were successful both from a clean state and
for subsequent runs.

Includes a new fact called 'postgres_default_version',
which detects what the default version of postgres is
for a given OS.  This is needed because some of the
commands and directory names include this version string.

Current implementation *only* supports managing the
system default version; in the future it would be nice
to allow the user to explicitly specify a postgres version,
but that isn't yet supported.

The "postgresql::server" class includes a call to postgres's
initdb command on redhat systems, because they don't do
this automatically when the package is installed.
2012-06-08 13:37:21 -07:00