Postgres Cluster (v2)
postgres_cluster_v2
This module supports creating, updating, restoring or destroying Postgres Clusters using the DBaaS PostgreSQL v2 API. The cluster region is selected through the I(location) option; I(api_url) overrides the base API URL globally (for a proxy/test endpoint, not for region selection).
Example Syntax
name: Create Cluster
ionoscloudsdk.ionoscloud.postgres_cluster_v2:
location: ''
postgres_version: '16'
instances: 1
cores: 1
ram: 4
storage_size: 10
connection:
datacenter: 'AnsibleAutoTestDBaaS - DBaaS v2'
lan: test_lan1
primary_instance_address: 192.168.1.101/24
name: ''
replication_mode: ASYNCHRONOUS
maintenance_window: ''
backup_location: ''
backup_retention_days: 7
db_username: clusteruser
db_password: 7357Cluster!x
db_database: testdb
wait: true
wait_timeout: ''
register: cluster_response
name: Update Cluster
ionoscloudsdk.ionoscloud.postgres_cluster_v2:
location: ''
postgres_cluster: ''
instances: 2
cores: 2
ram: 6
storage_size: 20
db_username: clusteruser
db_password: 7357Cluster!x
db_database: testdb
state: update
wait: true
wait_timeout: ''
register: updated_cluster_response
name: Restore Cluster (in-place)
ionoscloudsdk.ionoscloud.postgres_cluster_v2:
postgres_cluster: ''
recovery_target_time: "2023-07-01T13:00:00Z"
state: restore
wait: true
name: Delete Cluster (async)
ionoscloudsdk.ionoscloud.postgres_cluster_v2:
location: ''
postgres_cluster: ''
state: absent
wait: false
For more examples please check out the tests here.
NOTE: If you are using a versions 7.0.0 and up: modules can replace resources if certain set parameters differ from the results found in the API!
Parameters that can trigger a resource replacement:
connection
backup_location
state: present
Available parameters for state present:
maintenance_window dict
True
A weekly 4 hour-long window, during which maintenance might occur. A dict with keys `time` (start of the maintenance window in UTC, e.g. "16:30:00") and `day_of_the_week` (e.g. "Sunday").
postgres_version str
True
The PostgreSQL version for the cluster.
instances int
True
The total number of instances in the cluster (one primary and n-1 secondary).
cores int
True
The number of CPU cores per instance.
ram int
True
The amount of memory per instance in gigabytes (GB).
storage_size int
True
The amount of storage per instance in gigabytes (GB).
connection dict
True
Connection information of the PostgreSQL cluster. A dict with keys `datacenter` (ID or name), `lan` (ID or name) and `primary_instance_address` (IP and netmask of the cluster's primary instance, e.g. 192.168.1.101/24).
replication_mode str
True
Defines the replication mode across instances. - `ASYNCHRONOUS`: Propagates updates to other instances without waiting for confirmation. Offers higher performance but may result in temporary data inconsistencies during replication delays. - `STRICTLY_SYNCHRONOUS`: Only supported for clusters with at least 3 instances. Requires all instances to acknowledge the update before it is committed, guaranteeing strong consistency at the cost of potential performance impact in high-latency environments. Options: ['ASYNCHRONOUS', 'STRICTLY_SYNCHRONOUS']
name str
True
The name of your PostgreSQL cluster. Must be 63 characters or less and must begin and end with an alphanumeric character (`[a-z0-9A-Z]`) with dashes (`-`), underscores (`_`), dots (`.`), and alphanumerics between.
db_username str
True
The username of the master database user. Must be 16 characters or less and must include only alphanumeric characters (`[A-Za-z0-9_]`) and underscores (`_`).
db_password str
True
The password for the master database user. Must meet the following requirements: - At least 8 characters long. - Contains at least one lowercase letter. - Contains at least one uppercase letter. - Contains at least one digit (0-9). - Contains at least one special character from the set: @$!%*?&
db_database str
True
The name of the initial database to be created. Must be 63 characters or less and must include only alphanumeric characters (`[a-z0-9A-Z]`) and underscores (`_`).
connection_pooler str
False
Defines how database connections are managed and reused. Default value is DISABLED. DISABLED: No connection pooling is used. Each request opens a new connection, which is closed immediately after use. It ensures isolation but may impact performance due to frequent connection setup and teardown. TRANSACTION: Connections are pooled and reused for the duration of a transaction. Once the transaction completes, the connection is returned to the pool. This mode balances efficiency with transactional integrity. SESSION: Connections are retained for the entire session and reused across multiple transactions. Offers the highest performance by minimizing connection overhead, but may tie up resources longer. Options: ['DISABLED', 'TRANSACTION', 'SESSION']
backup_location str
True
The Object Storage location where the backup will be created. The BackupLocations provides a list of supported locations.
backup_retention_days int
True
Configures how many days cluster backups are retained.
logs_enabled bool
False
Allows or disallows the collection and reporting of logs for this cluster's observability. If the observability service is not activated on the contract, this setting is accepted but has no effect; log collection will not be enabled until the observability service is activated.
metrics_enabled bool
False
Allows or disallows the collection and reporting of metrics for this cluster's observability. If the observability service is not activated on the contract, this setting is accepted but has no effect; metric collection will not be enabled until the observability service is activated.
backup_id str
False
The ID of the backup to initialize the cluster from when creating (restore from an existing backup).
recovery_target_time str
False
Recovery target time (ISO 8601). Used to replay backups up to the specified time on creation, or for an in-place restore when state is `restore`.
location str
False
The location (region) in which the cluster will be created. Different service endpoints are used based on location, possible options are: "de/fra", "de/txl", "es/vit", "fr/par", "gb/lhr", "gb/bhx", "us/ewr", "us/las", "us/mci". If not set, the endpoint will be the one corresponding to "de/txl". The api_url, if set, overrides this.
allow_replace bool
False
Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead Default: False
api_url str
False
The Ionos API base URL.
certificate_fingerprint str
False
The Ionos API certificate fingerprint.
username str
False
The Ionos username. Overrides the IONOS_USERNAME environment variable.
password str
False
The Ionos password. Overrides the IONOS_PASSWORD environment variable.
token str
False
The Ionos token. Overrides the IONOS_TOKEN environment variable.
wait bool
False
Wait for the resource to be created before returning. Default: True Options: [True, False]
wait_timeout int
False
How long before wait gives up, in seconds. Default: 600
state str
False
Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update', 'restore']
state: absent
Available parameters for state absent:
postgres_cluster str
True
The ID or name of an existing Postgres Cluster.
location str
False
The location (region) in which the cluster will be created. Different service endpoints are used based on location, possible options are: "de/fra", "de/txl", "es/vit", "fr/par", "gb/lhr", "gb/bhx", "us/ewr", "us/las", "us/mci". If not set, the endpoint will be the one corresponding to "de/txl". The api_url, if set, overrides this.
api_url str
False
The Ionos API base URL.
certificate_fingerprint str
False
The Ionos API certificate fingerprint.
username str
False
The Ionos username. Overrides the IONOS_USERNAME environment variable.
password str
False
The Ionos password. Overrides the IONOS_PASSWORD environment variable.
token str
False
The Ionos token. Overrides the IONOS_TOKEN environment variable.
wait bool
False
Wait for the resource to be created before returning. Default: True Options: [True, False]
wait_timeout int
False
How long before wait gives up, in seconds. Default: 600
state str
False
Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update', 'restore']
state: update
Available parameters for state update:
maintenance_window dict
False
A weekly 4 hour-long window, during which maintenance might occur. A dict with keys `time` (start of the maintenance window in UTC, e.g. "16:30:00") and `day_of_the_week` (e.g. "Sunday").
postgres_version str
False
The PostgreSQL version for the cluster.
instances int
False
The total number of instances in the cluster (one primary and n-1 secondary).
cores int
False
The number of CPU cores per instance.
ram int
False
The amount of memory per instance in gigabytes (GB).
storage_size int
False
The amount of storage per instance in gigabytes (GB).
replication_mode str
False
Defines the replication mode across instances. - `ASYNCHRONOUS`: Propagates updates to other instances without waiting for confirmation. Offers higher performance but may result in temporary data inconsistencies during replication delays. - `STRICTLY_SYNCHRONOUS`: Only supported for clusters with at least 3 instances. Requires all instances to acknowledge the update before it is committed, guaranteeing strong consistency at the cost of potential performance impact in high-latency environments. Options: ['ASYNCHRONOUS', 'STRICTLY_SYNCHRONOUS']
name str
False
The name of your PostgreSQL cluster. Must be 63 characters or less and must begin and end with an alphanumeric character (`[a-z0-9A-Z]`) with dashes (`-`), underscores (`_`), dots (`.`), and alphanumerics between.
db_username str
True
The username of the master database user. Must be 16 characters or less and must include only alphanumeric characters (`[A-Za-z0-9_]`) and underscores (`_`).
db_password str
True
The password for the master database user. Must meet the following requirements: - At least 8 characters long. - Contains at least one lowercase letter. - Contains at least one uppercase letter. - Contains at least one digit (0-9). - Contains at least one special character from the set: @$!%*?&
db_database str
True
The name of the initial database to be created. Must be 63 characters or less and must include only alphanumeric characters (`[a-z0-9A-Z]`) and underscores (`_`).
connection_pooler str
False
Defines how database connections are managed and reused. Default value is DISABLED. DISABLED: No connection pooling is used. Each request opens a new connection, which is closed immediately after use. It ensures isolation but may impact performance due to frequent connection setup and teardown. TRANSACTION: Connections are pooled and reused for the duration of a transaction. Once the transaction completes, the connection is returned to the pool. This mode balances efficiency with transactional integrity. SESSION: Connections are retained for the entire session and reused across multiple transactions. Offers the highest performance by minimizing connection overhead, but may tie up resources longer. Options: ['DISABLED', 'TRANSACTION', 'SESSION']
backup_retention_days int
False
Configures how many days cluster backups are retained.
logs_enabled bool
False
Allows or disallows the collection and reporting of logs for this cluster's observability. If the observability service is not activated on the contract, this setting is accepted but has no effect; log collection will not be enabled until the observability service is activated.
metrics_enabled bool
False
Allows or disallows the collection and reporting of metrics for this cluster's observability. If the observability service is not activated on the contract, this setting is accepted but has no effect; metric collection will not be enabled until the observability service is activated.
postgres_cluster str
True
The ID or name of an existing Postgres Cluster.
location str
False
The location (region) in which the cluster will be created. Different service endpoints are used based on location, possible options are: "de/fra", "de/txl", "es/vit", "fr/par", "gb/lhr", "gb/bhx", "us/ewr", "us/las", "us/mci". If not set, the endpoint will be the one corresponding to "de/txl". The api_url, if set, overrides this.
allow_replace bool
False
Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead Default: False
api_url str
False
The Ionos API base URL.
certificate_fingerprint str
False
The Ionos API certificate fingerprint.
username str
False
The Ionos username. Overrides the IONOS_USERNAME environment variable.
password str
False
The Ionos password. Overrides the IONOS_PASSWORD environment variable.
token str
False
The Ionos token. Overrides the IONOS_TOKEN environment variable.
wait bool
False
Wait for the resource to be created before returning. Default: True Options: [True, False]
wait_timeout int
False
How long before wait gives up, in seconds. Default: 600
state str
False
Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update', 'restore']
state: restore
Available parameters for state restore:
db_username str
True
The username of the master database user. Must be 16 characters or less and must include only alphanumeric characters (`[A-Za-z0-9_]`) and underscores (`_`).
db_password str
True
The password for the master database user. Must meet the following requirements: - At least 8 characters long. - Contains at least one lowercase letter. - Contains at least one uppercase letter. - Contains at least one digit (0-9). - Contains at least one special character from the set: @$!%*?&
db_database str
True
The name of the initial database to be created. Must be 63 characters or less and must include only alphanumeric characters (`[a-z0-9A-Z]`) and underscores (`_`).
recovery_target_time str
True
Recovery target time (ISO 8601). Used to replay backups up to the specified time on creation, or for an in-place restore when state is `restore`.
postgres_cluster str
True
The ID or name of an existing Postgres Cluster.
location str
False
The location (region) in which the cluster will be created. Different service endpoints are used based on location, possible options are: "de/fra", "de/txl", "es/vit", "fr/par", "gb/lhr", "gb/bhx", "us/ewr", "us/las", "us/mci". If not set, the endpoint will be the one corresponding to "de/txl". The api_url, if set, overrides this.
api_url str
False
The Ionos API base URL.
certificate_fingerprint str
False
The Ionos API certificate fingerprint.
username str
False
The Ionos username. Overrides the IONOS_USERNAME environment variable.
password str
False
The Ionos password. Overrides the IONOS_PASSWORD environment variable.
token str
False
The Ionos token. Overrides the IONOS_TOKEN environment variable.
wait bool
False
Wait for the resource to be created before returning. Default: True Options: [True, False]
wait_timeout int
False
How long before wait gives up, in seconds. Default: 600
state str
False
Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update', 'restore']
Last updated
Was this helpful?