# risotto.postgresql - Configure the PostgreSQL server This repository contains the `risotto.postgresql` Ansible Collection. PostgreSQL is the World's Most Advanced Open Source Relational Database. This collection allows you to configure a PostgreSQL server and create user accounts. ## Variables ### The group variable "postgresql" - Configure the PostgreSQL server | Variable | Description | Default value | Type | Validator | |----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|-------------------------------------------------------------------------------------------------|---------------------------------------------------------| | **max_connections** | The maximum number of concurrent connections. | 100 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **authentication_timeout** | The maximum allowed time to complete client authentication.
In seconds. | 60 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **autovacuum** | Starts the autovacuum subprocess. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **work_mem** | The maximum memory to be used for query workspaces.
Sets the base maximum amount of memory to be used by a query operation (such as a sort or hash table) before writing to temporary disk files. | 4 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **work_mem_unit** | Unit of work_mem. | MB | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | **Choices**:
• kB
• MB | | **maintenance_work_mem** | The maximum memory to be used for maintenance operations.
Specifies the maximum amount of memory to be used by maintenance operations, such as VACUUM, CREATE INDEX, and ALTER TABLE ADD FOREIGN KEY. | 64 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **maintenance_work_mem_unit** | Unit of maintenance_work_mem parameter. | MB | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | **Choices**:
• kB
• MB | | **wal_buffers** | The number of disk-page buffers in shared memory for WAL.
The amount of shared memory used for WAL data that has not yet been written to disk (The default setting of -1 selects a size equal to 1/32nd of shared_buffers, but not less than 64kB nor more than the size of one WAL segment). | -1 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **max_wal_size** | The WAL size that triggers a checkpoint.
Maximum (soft limit) size to let the WAL grow during automatic checkpoints. | 2 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **max_wal_size_unit** | Unité de la limite douce du Write Ahead Log. | GB | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | **Choices**:
• GB
• MB
• kB | | **shared_buffers** | The number of shared memory buffers used by the server. | 128 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **shared_buffers_unit** | Unit of shared_buffers. | MB | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | **Choices**:
• MB
• kB | | **effective_cache_size** | Sets the planner's assumption about the total size of the data caches.
Sets the planner's assumption about the effective size of the disk cache that is available to a single query. | 4 | [`integer`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | | **effective_cache_size_unit** | Unit of effective_cache_size. | GB | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | **Choices**:
• MB
• kB
• GB | ### The group variable "accounts" - Accounts to the PostgreSQL server | Variable | Description | Type | Validator | |------------------------------------------------------------------|----------------------------|---------------------------------------------------------------------------------------------------------------|-------------------------------| | **remotes** | PostgreSQL client address. | [`domainname`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `mandatory` | `unique`
Type domainname. | #### Account for *example* > [!NOTE] > > This family builds families dynamically.\ > **Path**: remote_*example*\ > **Identifiers**: the value of the variable "[PostgreSQL client address](#accounts.remotes)". | Variable | Description | Type | |--------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|---------------------------------------------------------------------------------------------------| | **remote_*example*.database** | PostgreSQL database name for *example*. | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | **remote_*example*.username** | PostgreSQL username for *example*. | [`UNIX user`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | **remote_*example*.password** | PostgreSQL password for *example*. | [`secret`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | ## Usage ### Example playbook with Rougail Add to your structural file something like: ```yaml %YAML 1.2 --- version: 1.1 my_postgresql: type: postgresql my_accounts: type: accounts ... ``` > [!NOTE] > > Do not forget to add Rougail structural file as Rougail types. For example you can add an YAML user data with something like: ```yaml --- my_accounts: remotes: # PostgreSQL client address - example.net remote_example_net: # Account for example.net database: example # PostgreSQL database name for example.net username: username # PostgreSQL username for example.net password: secrets # PostgreSQL password for example.net ``` Add to your playbook: ```yaml --- - name: Configure the PostgreSQL server hosts: servers vars: postgresql: '{{ my_postgresql }}' accounts: '{{ my_accounts }}' roles: - role: risotto.postgresql ``` ### Example playbook without Rougail > [!NOTE] > > The variables will not be properly validated without Rougail. ```yaml --- - name: Configure the PostgreSQL server hosts: servers vars: accounts: remotes: # PostgreSQL client address - example.net remote_example_net: # Account for example.net database: example # PostgreSQL database name for example.net username: username # PostgreSQL username for example.net password: secrets # PostgreSQL password for example.net roles: - role: risotto.postgresql ```