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: 'de/fra'
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: 'ansible-test-v2'
replication_mode: ASYNCHRONOUS
maintenance_window: ''
backup_location: 'eu-central-3'
backup_retention_days: 7
db_username: clusteruser
db_password: ''
db_database: testdb
wait: true
wait_timeout: '3600'
register: cluster_response
name: Update Cluster
ionoscloudsdk.ionoscloud.postgres_cluster_v2:
location: 'de/fra'
postgres_cluster: ''
instances: 2
cores: 2
ram: 6
storage_size: 20
db_username: clusteruser
db_password: ''
db_database: testdb
state: update
wait: true
wait_timeout: '3600'
register: updated_cluster_response
name: Restore Cluster (in-place)
ionoscloudsdk.ionoscloud.postgres_cluster_v2:
location: 'de/fra'
postgres_cluster: ''
recovery_target_time: ''
db_username: clusteruser
db_password: ''
db_database: testdb
state: restore
wait: true
wait_timeout: '3600'
register: restored_cluster_response
name: Delete Cluster (async)
ionoscloudsdk.ionoscloud.postgres_cluster_v2:
location: 'de/fra'
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.
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. 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 database user to create or update. 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 database user. Must be between 8 and 256 characters long. For a strong password we recommend that it also meets the following criteria, though these are not enforced: - 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 database to create and grant the user access to. 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`. Options: ['DISABLED', 'TRANSACTION', 'SESSION']
backup_location str
True
The Object Storage location where the backup is created. The BackupLocations operations provide a list of supported locations.
backup_retention_days int
True
The number of days cluster backups are retained. Accepted values are 1 to 365. Pre-existing clusters default to 7 days. If you reduce this value, backups older than the new window are purged.
logs_enabled bool
False
Activates or deactivates 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 does not start until the observability service is active.
metrics_enabled bool
False
Activates or deactivates 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 does not start until the observability service is active.
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.
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. 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 database user to create or update. 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 database user. Must be between 8 and 256 characters long. For a strong password we recommend that it also meets the following criteria, though these are not enforced: - 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 database to create and grant the user access to. 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`. Options: ['DISABLED', 'TRANSACTION', 'SESSION']
backup_retention_days int
False
The number of days cluster backups are retained. Accepted values are 1 to 365. Pre-existing clusters default to 7 days. If you reduce this value, backups older than the new window are purged.
logs_enabled bool
False
Activates or deactivates 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 does not start until the observability service is active.
metrics_enabled bool
False
Activates or deactivates 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 does not start until the observability service is active.
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 database user to create or update. 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 database user. Must be between 8 and 256 characters long. For a strong password we recommend that it also meets the following criteria, though these are not enforced: - 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 database to create and grant the user access to. 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?