Commit graph

38 commits

Author SHA1 Message Date
Tom Hey
6a29636155 (MODULES-661) Remote DB support
Adds connection-settings (for remote DB support) when creating DB resources.

Connection-settings allows a hash of options that can be used
when connecting the a remote DB (such as PGHOST, PGPORT, PGPASSWORD
PGSSLKEY) and a special option DBVERSION indicating the version
of the remote database.

Including
- Puppet updates
- Documentation updates
- RSpec unit test updates
- RSpec acceptance test updates
- Some test coverage for connection-settings
- Working acceptance test...
    Basic vagrant setup:
    * Two boxes, server and client
    * Runs puppet code to on server to setup a postgres server that allows all connections and md5 connections, creates db puppet to look at
    * Runs puppet code on client to make a server that a psql command can be run against puppet db on other server
    * Does some fancy stuff to get the fact of the IP from the first server to connect to
- Backwards compatible, with deprecation warnings around old parameters
2015-08-27 11:03:18 +01:00
Dominic Cleal
c3d853d22e (MODULES-2185) Fix withenv execution under Puppet 2.7
When executing a command with environment variables, the withenv helper
under Puppet 2.7 is on Puppet::Util::Execution and on 3.0 to 3.3, it's
on Puppet::Util.
2015-07-02 18:12:28 +01:00
Bryan Jen
90290f6111 (FM-2931) fixes logic problem with onlyif type param validation. 2015-06-29 10:14:39 -07:00
Kimo Rosenbaum
39f15c313c Add onlyif parameter to postgresql_psql to only run command if onlyif returns true
Add option to only attempt table grant if table already exists

Make this slightly more generic
2015-06-25 13:54:02 -07:00
Roman Mueller
460623e3a1 (MODULES-2007) Fix Puppet.newtype deprecation warning 2015-05-05 00:04:43 +02:00
Morgan Haskel
9723b7d040 MODULES-1923 - Use the correct command with Puppet < 3.4 2015-04-09 14:29:36 -07:00
Hunter Haugen
8204bcdcaf Fix the handling of run_unless_sql_command in puppet 4
`Puppet::Util::SUIDManager.run_and_capture` (in puppet < 3.4) returns an
array of the output and the `Process::Status` object.
`Puppet::Util::Execution.execute` (in puppet >= 3.4) returns the output
and saves the `Process::Status` object to `$CHILD_STATUS`

This is handled in the provider, but the type was also trying to handle
it, and was not last updated when the provider was.
2015-03-13 15:20:27 -07:00
Krzysztof Suszyński
a9b16b6ccf I've added some acceptance tests to 100% check that my method is valid and passwords ane not placed in report 2015-03-12 10:57:20 -07:00
Krzysztof Suszyński
cfbf2f9308 Using enviromental varables to hide actual password in psql commands displayed in output and reports. 2015-03-12 10:57:19 -07:00
Hunter Haugen
a50a16d97d Merge pull request #580 from raphink/dev/replication
Replication type
2015-03-12 10:18:42 -07:00
Raphaël Pinson
76ab6f1160 Add a postgresql_replication_slot type 2015-03-12 18:14:58 +01:00
Morgan Haskel
8295b488cc Revert "(MODULES-661) Add host parameter to psql commands"
This reverts commit d92b2545e2.

Conflicts:
	spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb
2015-03-09 17:00:06 -07:00
Peter Souter
d92b2545e2 (MODULES-661) Add host parameter to psql commands
This allows you to use `postgres_pqsl` commands to be run against a specified host. The ultimate goal being that you can use `puppetlabs-postsgresql` to run against remote instances, especially things such as Amazons RDS service.

This PR will be further extended to do things like allow remote `table_grant` and the like.
2015-03-03 17:13:37 +00:00
Morgan Haskel
5dd5428202 Fix errors with future parser 2014-11-03 16:11:06 -08:00
Dominic Cleal
b7cbe60d4b (MODULES-775) Fix refresh/unless parameter interactions
Interactions between resource refreshes and the 'unless' parameter have been
fixed to follow the behaviour of the 'exec' type.

The 'unless' parameter is now always taken into account, whether in ordinary
operation, during a refresh, or when refreshonly is set to true.  The resource
will not run the SQL command when the 'unless' clause matches a row.

Previously a refresh on a resource would ignore the 'unless' parameter if set
which could cause a failure re-running a command, such as attempting to create
a role that already exists.

The following examples have been fixed:

  * should not run SQL when refreshed and the unless query returns rows
  * with refreshonly should not run SQL when the unless query returns no rows
  * with refreshonly should not run SQL when refreshed and the unless query
    returns rows

This is done by moving the logic for refreshonly and whether to run the SQL
command from the provider into the type, and consolidating it in the
should_run_sql method which is called during 'command' property retrieval
(instead of sync) and during refresh.
2014-06-03 10:25:13 +01:00
Brian Almeida
86f2950248 Add support for port parameter to postgresql::server, fix underlying assumptions that port=5432 2014-04-17 15:09:07 -04:00
Reid Vandewiele
0573c158a2 Fix postgresql_conf quote logic
Things like IP addresses DO need to be in quotes. Fixing regex to reflect
requirement.
2014-03-31 09:29:03 -07:00
Joshua Hoblitt
658e20afb5 use Puppet::Util::Execute.execute with puppet >= 3.4
Resolves this warning on puppet 3.4.2:

    Warning: Puppet::Util::SUIDManager.run_and_capture is deprecated; please
    use Puppet::Util::Execution.execute instead.

This patch also fixes the postgresql_psql provider's broken puppet "4"
support.
2014-01-07 16:12:53 -07:00
Ashley Penney
878bf49617 (FM-486) Fix deprecated Puppet::Util::SUIDManager.run_and_capture
Puppet::Util::SUIDManager.run_and_capture recently changed to
Execution.execute, switch before it blows up and stops working.
2013-11-22 14:45:37 -08:00
Ashley Penney
712e5fc7f4 Merge pull request #284 from 3dna/conf_allows_dots
periods are valid in configuration variables also
2013-10-21 14:26:44 -07:00
Jeremy Kitchen
66ef240614 test and fix for dots breaking config keys 2013-10-18 23:02:11 +00:00
Jeremy Kitchen
9776602e49 periods are valid in configuration variables also
example:
http://www.postgresql.org/docs/9.2/static/auto-explain.html
2013-10-18 21:33:37 +00:00
Jeremy Kitchen
38e82ede57 add search_path attribute to postgresql_psql resource
This allows you to set a schema search_path on postgresql_psql
resources, in case you have multiple schemas in your database and the
SQL you are trying to run requires a different path
2013-10-14 22:00:21 +00:00
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
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
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
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
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