You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Copy file name to clipboardExpand all lines: README.md
+61-1
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,43 @@ In this example, you would grant ALL privileges on the test1 database and on the
120
120
121
121
At this point, you would just need to plunk these database name/username/password values into your PuppetDB config files, and you are good to go.
122
122
123
+
###Managing remote users, roles and permissions
124
+
125
+
Remote SQL objects are managed using the same Puppet resources as local SQL objects with the additional of a connect_settings hash. This provides control over how Puppet should connect to the remote Postgres instances and the version that should be used when generating SQL commands.
126
+
127
+
When provided the connect_settings hash can contain environment variables to control Postgres client connections, such as: PGHOST, PGPORT, PGPASSWORD PGSSLKEY (see http://www.postgresql.org/docs/9.4/static/libpq-envars.html) Additionally the special value of DBVERSION can be provided to specify the target database's version. If the connect_settings hash is omitted or empty then Puppet will connect to the local Postgres instance.
128
+
129
+
A connect_settings hash can be provided with each of the Puppet resources or a default connect_settings hash can be set in postgresql::globals. Per resource configuration of connect_settings allows for SQL object to be creating on multiple database by multiple users.
130
+
131
+
$connection_settings_super2 = {
132
+
'PGUSER' => "super2",
133
+
'PGPASSWORD' => "foobar2",
134
+
'PGHOST' => "127.0.0.1",
135
+
'PGPORT' => "5432",
136
+
'PGDATABASE' => "postgres",
137
+
}
138
+
139
+
include postgresql::server
140
+
141
+
# Connect with no special settings, i.e domain sockets, user postges
142
+
postgresql::server::role{'super2':
143
+
password_hash => "foobar2",
144
+
superuser => true,
145
+
146
+
connect_settings => {},
147
+
require => [
148
+
Class['postgresql::globals'],
149
+
Class['postgresql::server::service'],
150
+
],
151
+
}
152
+
153
+
# Now using this new user connect via TCP
154
+
postgresql::server::database { 'db1':
155
+
connect_settings => $connection_settings_super2,
156
+
157
+
require => Postgresql::Server::Role['super2'],
158
+
}
159
+
123
160
Reference
124
161
---------
125
162
@@ -241,6 +278,7 @@ This setting is used to specify the name of the default database to connect with
241
278
Path to the `initdb` command.
242
279
243
280
####`createdb_path`
281
+
**Deprecated**
244
282
Path to the `createdb` command.
245
283
246
284
####`psql_path`
@@ -370,6 +408,7 @@ List of strings for access control for connection method, users, databases, IPv6
370
408
Path to the `initdb` command.
371
409
372
410
####`createdb_path`
411
+
**Deprecated**
373
412
Path to the `createdb` command.
374
413
375
414
####`psql_path`
@@ -539,7 +578,7 @@ Value for the setting.
539
578
540
579
541
580
###Resource: postgresql::server::db
542
-
This is a convenience resource that creates a database, user and assigns necessary permissions in one go.
581
+
This is a convenience resource that creates a local database, user and assigns necessary permissions in one go.
543
582
544
583
For example, to create a database called `test1` with a corresponding user of the same name, you can use:
545
584
@@ -612,6 +651,8 @@ Override the locale during creation of the database. Defaults to the default def
612
651
####`istemplate`
613
652
Define database as a template. Defaults to `false`.
614
653
654
+
####`connect_settings`
655
+
Hash of environment variable used when connecting to a remote server. Defaults to connecting to the local Postgres instance.
615
656
616
657
###Resource: postgresql::server::database\_grant
617
658
This defined type manages grant based access privileges for users, wrapping the `postgresql::server::database_grant` for database specific permissions. Consult the PostgreSQL documentation for `grant` for more information.
@@ -634,6 +675,8 @@ Database to execute the grant against. This should not ordinarily be changed fro
634
675
####`psql_user`
635
676
OS user for running `psql`. Defaults to the default user for the module, usually `postgres`.
636
677
678
+
####`connect_settings`
679
+
Hash of environment variable used when connecting to a remote server. Defaults to connecting to the local Postgres instance.
637
680
638
681
###Resource: postgresql::server::extension
639
682
Manages a postgresql extension.
@@ -683,6 +726,9 @@ OS user for running `psql`. Defaults to the default user for the module, usually
683
726
####`port`
684
727
Port to use when connecting. Default to 'undef' which generally defaults to 5432 depending on your PostgreSQL packaging.
685
728
729
+
####`connect_settings`
730
+
Hash of environment variable used when connecting to a remote server. Defaults to connecting to the local Postgres instance.
731
+
686
732
###Resource: postgresql::server::pg\_hba\_rule
687
733
This defined type allows you to create an access rule for `pg_hba.conf`. For more details see the [PostgreSQL documentation](http://www.postgresql.org/docs/8.2/static/auth-pg-hba-conf.html).
688
734
@@ -886,6 +932,9 @@ Specifies how many concurrent connections the role can make. Defaults to `-1` me
886
932
####`username`
887
933
The username of the role to create, defaults to `namevar`.
888
934
935
+
####`connect_settings`
936
+
Hash of environment variable used when connecting to a remote server. Defaults to connecting to the local Postgres instance.
937
+
889
938
###Resource: postgresql::server::schema
890
939
This defined type can be used to create a schema. For example:
891
940
@@ -909,6 +958,9 @@ The default owner of the schema.
909
958
####`schema`
910
959
Name of the schma. Defaults to `namevar`.
911
960
961
+
####`connect_settings`
962
+
Hash of environment variable used when connecting to a remote server. Defaults to connecting to the local Postgres instance.
963
+
912
964
913
965
###Resource: postgresql::server::table\_grant
914
966
This defined type manages grant based access privileges for users. Consult the PostgreSQL documentation for `grant` for more information.
@@ -934,6 +986,8 @@ Database to execute the grant against. This should not ordinarily be changed fro
934
986
####`psql_user`
935
987
OS user for running `psql`. Defaults to the default user for the module, usually `postgres`.
936
988
989
+
####`connect_settings`
990
+
Hash of environment variable used when connecting to a remote server. Defaults to connecting to the local Postgres instance.
937
991
938
992
###Resource: postgresql::server::tablespace
939
993
This defined type can be used to create a tablespace. For example:
@@ -957,8 +1011,11 @@ The default owner of the tablespace.
957
1011
####`spcname`
958
1012
Name of the tablespace. Defaults to `namevar`.
959
1013
1014
+
####`connect_settings`
1015
+
Hash of environment variable used when connecting to a remote server. Defaults to connecting to the local Postgres instance.
960
1016
961
1017
###Resource: postgresql::validate\_db\_connection
1018
+
962
1019
This resource can be utilised inside composite manifests to validate that a client has a valid connection with a remote PostgreSQL database. It can be ran from any node where the PostgreSQL client software is installed to validate connectivity before commencing other dependent tasks in your Puppet manifests, so it is often used when chained to other tasks such as: starting an application server, performing a database migration.
963
1020
964
1021
Example usage:
@@ -991,6 +1048,9 @@ Username to connect with. Defaults to 'undef', which when using a unix socket an
991
1048
####`database_password`
992
1049
Password to connect with. Can be left blank, but that is not recommended.
993
1050
1051
+
####`connect_settings`
1052
+
Hash of environment variable used when connecting to a remote server, this is an alternative to providing individual parameters (database_host, etc.). If provided the individual parameters take precedence.
1053
+
994
1054
####`run_as`
995
1055
The user to run the `psql` command with for authenticiation. This is important when trying to connect to a database locally using Unix sockets and `ident` authentication. It is not needed for remote testing.
0 commit comments