Skip to content

variables to parameters for tablespace/schema/reassign_owned_by #1507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3279,6 +3279,8 @@ The following parameters are available in the `postgresql::server::reassign_owne
* [`psql_user`](#-postgresql--server--reassign_owned_by--psql_user)
* [`port`](#-postgresql--server--reassign_owned_by--port)
* [`connect_settings`](#-postgresql--server--reassign_owned_by--connect_settings)
* [`group`](#-postgresql--server--reassign_owned_by--group)
* [`psql_path`](#-postgresql--server--reassign_owned_by--psql_path)

##### <a name="-postgresql--server--reassign_owned_by--old_role"></a>`old_role`

Expand Down Expand Up @@ -3322,6 +3324,22 @@ Specifies a hash of environment variables used when connecting to a remote serve

Default value: `$postgresql::server::default_connect_settings`

##### <a name="-postgresql--server--reassign_owned_by--group"></a>`group`

Data type: `String[1]`

Sets the OS group to run psql

Default value: `$postgresql::server::group`

##### <a name="-postgresql--server--reassign_owned_by--psql_path"></a>`psql_path`

Data type: `Stdlib::Absolutepath`

Sets the path to psql command

Default value: `$postgresql::server::psql_path`

### <a name="postgresql--server--recovery"></a>`postgresql::server::recovery`

This resource manages the parameters that applies to the recovery.conf template.
Expand Down Expand Up @@ -3698,6 +3716,10 @@ The following parameters are available in the `postgresql::server::schema` defin
* [`schema`](#-postgresql--server--schema--schema)
* [`connect_settings`](#-postgresql--server--schema--connect_settings)
* [`port`](#-postgresql--server--schema--port)
* [`user`](#-postgresql--server--schema--user)
* [`group`](#-postgresql--server--schema--group)
* [`psql_path`](#-postgresql--server--schema--psql_path)
* [`module_workdir`](#-postgresql--server--schema--module_workdir)

##### <a name="-postgresql--server--schema--db"></a>`db`

Expand Down Expand Up @@ -3739,6 +3761,39 @@ the post the postgresql instance is listening on.

Default value: `$postgresql::server::port`

##### <a name="-postgresql--server--schema--user"></a>`user`

Data type: `String[1]`

Sets the OS user to run psql

Default value: `$postgresql::server::user`

##### <a name="-postgresql--server--schema--group"></a>`group`

Data type: `String[1]`

Sets the OS group to run psql

Default value: `$postgresql::server::group`

##### <a name="-postgresql--server--schema--psql_path"></a>`psql_path`

Data type: `Stdlib::Absolutepath`

Sets path to psql command

Default value: `$postgresql::server::psql_path`

##### <a name="-postgresql--server--schema--module_workdir"></a>`module_workdir`

Data type: `Stdlib::Absolutepath`

Specifies working directory under which the psql command should be executed.
May need to specify if '/tmp' is on volume mounted with noexec option.

Default value: `$postgresql::server::module_workdir`

### <a name="postgresql--server--table_grant"></a>`postgresql::server::table_grant`

This resource wraps the grant resource to manage table grants specifically.
Expand Down Expand Up @@ -3850,6 +3905,10 @@ The following parameters are available in the `postgresql::server::tablespace` d
* [`spcname`](#-postgresql--server--tablespace--spcname)
* [`connect_settings`](#-postgresql--server--tablespace--connect_settings)
* [`port`](#-postgresql--server--tablespace--port)
* [`user`](#-postgresql--server--tablespace--user)
* [`group`](#-postgresql--server--tablespace--group)
* [`psql_path`](#-postgresql--server--tablespace--psql_path)
* [`module_workdir`](#-postgresql--server--tablespace--module_workdir)

##### <a name="-postgresql--server--tablespace--location"></a>`location`

Expand Down Expand Up @@ -3897,6 +3956,39 @@ the port of the postgresql instance that sould be used.

Default value: `$postgresql::server::port`

##### <a name="-postgresql--server--tablespace--user"></a>`user`

Data type: `String[1]`

Sets the OS user to run psql

Default value: `$postgresql::server::user`

##### <a name="-postgresql--server--tablespace--group"></a>`group`

Data type: `String[1]`

Sets the OS group to run psql

Default value: `$postgresql::server::group`

##### <a name="-postgresql--server--tablespace--psql_path"></a>`psql_path`

Data type: `Stdlib::Absolutepath`

Sets path to psql command

Default value: `$postgresql::server::psql_path`

##### <a name="-postgresql--server--tablespace--module_workdir"></a>`module_workdir`

Data type: `String[1]`

Specifies working directory under which the psql command should be executed.
May need to specify if '/tmp' is on volume mounted with noexec option.

Default value: `$postgresql::server::module_workdir`

## Resource types

### <a name="postgresql_conf"></a>`postgresql_conf`
Expand Down Expand Up @@ -4062,6 +4154,7 @@ The following parameters are available in the `postgresql_psql` type.
* [`cwd`](#-postgresql_psql--cwd)
* [`db`](#-postgresql_psql--db)
* [`environment`](#-postgresql_psql--environment)
* [`instance`](#-postgresql_psql--instance)
* [`name`](#-postgresql_psql--name)
* [`onlyif`](#-postgresql_psql--onlyif)
* [`port`](#-postgresql_psql--port)
Expand Down Expand Up @@ -4094,6 +4187,12 @@ Any additional environment variables you want to set for a
SQL command. Multiple environment variables should be
specified as an array.

##### <a name="-postgresql_psql--instance"></a>`instance`

The postgresql instance under which the psql command should be executed.

Default value: `main`

##### <a name="-postgresql_psql--name"></a>`name`

namevar
Expand Down
13 changes: 7 additions & 6 deletions manifests/server/reassign_owned_by.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
# @param psql_user Specifies the OS user for running psql.
# @param port Port to use when connecting.
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.
# @param group Sets the OS group to run psql
# @param psql_path Sets the path to psql command
define postgresql::server::reassign_owned_by (
String $old_role,
String $new_role,
String $db,
String $psql_user = $postgresql::server::user,
Stdlib::Port $port = $postgresql::server::port,
Hash $connect_settings = $postgresql::server::default_connect_settings,
String $psql_user = $postgresql::server::user,
Stdlib::Port $port = $postgresql::server::port,
Hash $connect_settings = $postgresql::server::default_connect_settings,
String[1] $group = $postgresql::server::group,
Stdlib::Absolutepath $psql_path = $postgresql::server::psql_path,
) {
$sql_command = "REASSIGN OWNED BY \"${old_role}\" TO \"${new_role}\""

$group = $postgresql::server::group
$psql_path = $postgresql::server::psql_path

$port_override = pick($connect_settings['PGPORT'], $port)

$onlyif = "SELECT tablename FROM pg_catalog.pg_tables WHERE
Expand Down
25 changes: 15 additions & 10 deletions manifests/server/schema.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@
# @param schema Sets the name of the schema.
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.
# @param port the post the postgresql instance is listening on.
# @param user Sets the OS user to run psql
# @param group Sets the OS group to run psql
# @param psql_path Sets path to psql command
# @param module_workdir
# Specifies working directory under which the psql command should be executed.
# May need to specify if '/tmp' is on volume mounted with noexec option.
# @example
# postgresql::server::schema {'private':
# db => 'template1',
# }
define postgresql::server::schema (
String[1] $db = $postgresql::server::default_database,
Optional[String[1]] $owner = undef,
String[1] $schema = $title,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Stdlib::Port $port = $postgresql::server::port,
String[1] $db = $postgresql::server::default_database,
Optional[String[1]] $owner = undef,
String[1] $schema = $title,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Stdlib::Port $port = $postgresql::server::port,
String[1] $user = $postgresql::server::user,
String[1] $group = $postgresql::server::group,
Stdlib::Absolutepath $psql_path = $postgresql::server::psql_path,
Stdlib::Absolutepath $module_workdir = $postgresql::server::module_workdir,
) {
$user = $postgresql::server::user
$group = $postgresql::server::group
$psql_path = $postgresql::server::psql_path
$module_workdir = $postgresql::server::module_workdir

Postgresql::Server::Db <| dbname == $db |> -> Postgresql::Server::Schema[$name]

# If the connection settings do not contain a port, then use the local server port
Expand Down
27 changes: 16 additions & 11 deletions manifests/server/tablespace.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@
# @param spcname Specifies the name of the tablespace.
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.
# @param port the port of the postgresql instance that sould be used.
# @param user Sets the OS user to run psql
# @param group Sets the OS group to run psql
# @param psql_path Sets path to psql command
# @param module_workdir
# Specifies working directory under which the psql command should be executed.
# May need to specify if '/tmp' is on volume mounted with noexec option.
define postgresql::server::tablespace (
String[1] $location,
Boolean $manage_location = true,
Optional[String[1]] $owner = undef,
String[1] $spcname = $title,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Stdlib::Port $port = $postgresql::server::port,
String[1] $location,
Boolean $manage_location = true,
Optional[String[1]] $owner = undef,
String[1] $spcname = $title,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Stdlib::Port $port = $postgresql::server::port,
String[1] $user = $postgresql::server::user,
String[1] $group = $postgresql::server::group,
Stdlib::Absolutepath $psql_path = $postgresql::server::psql_path,
String[1] $module_workdir = $postgresql::server::module_workdir,
) {
$user = $postgresql::server::user
$group = $postgresql::server::group
$psql_path = $postgresql::server::psql_path
$module_workdir = $postgresql::server::module_workdir

# If the connection settings do not contain a port, then use the local server port
$port_override = pick($connect_settings['PGPORT'], $port)

Expand Down