Postgres Cluster

postgres_cluster

This is a module that supports creating, updating, restoring or destroying Postgres Clusters

Example Syntax


name: Create Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
  postgres_version: 12
  instances: 1
  cores: 1
  ram: 2048
  storage_size: 20480
  storage_type: SSD Premium
  location: de/fra
  backup_location: eu-central-2
  connections:
  - cidr: 192.168.1.106/24
    datacenter: 'AnsibleAutoTestDBaaS - DBaaS'
    lan: test_lan1
  display_name: backuptest-04
  synchronization_mode: ASYNCHRONOUS
  db_username: clusteruser
  db_password: 7357cluster
  wait: true
register: cluster_response


name: Update Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
  postgres_cluster: ''
  instances: 2
  cores: 2
  ram: 4096
  storage_size: 30480
  state: update
  wait: true
register: updated_cluster_response


name: Delete Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
  postgres_cluster: ''
  state: absent
  wait: false

Returned object

{
    "changed": true,
    "failed": false,
    "action": "create",
    "postgres_cluster": {
        "type": "cluster",
        "id": "46c151c7-55f8-42a4-86c3-06ad6b4b91ea",
        "metadata": {
            "created_date": "2023-05-30T14:35:40+00:00",
            "created_by": "<USER_EMAIL>",
            "created_by_user_id": "<USER_ID>",
            "last_modified_date": null,
            "last_modified_by": null,
            "last_modified_by_user_id": null,
            "state": "BUSY"
        },
        "properties": {
            "display_name": "backuptest-04",
            "postgres_version": "12",
            "location": "de/fra",
            "backup_location": "eu-central-2",
            "instances": 1,
            "ram": 2048,
            "cores": 1,
            "storage_size": 20480,
            "storage_type": "SSD Premium",
            "connections": [
                {
                    "datacenter_id": "03a8fdf1-fbc4-43f6-91ce-0506444e17dd",
                    "lan_id": "2",
                    "cidr": "<CIDR>"
                }
            ],
            "maintenance_window": {
                "time": "12:15:19",
                "day_of_the_week": "Monday"
            },
            "synchronization_mode": "ASYNCHRONOUS"
        }
    }
}

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:

  • connections

  • backup_location

  • location

  • synchronization_mode

  • storage_type

state: present

  
name: Create Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
  postgres_version: 12
  instances: 1
  cores: 1
  ram: 2048
  storage_size: 20480
  storage_type: SSD Premium
  location: de/fra
  backup_location: eu-central-2
  connections:
  - cidr: 192.168.1.106/24
    datacenter: 'AnsibleAutoTestDBaaS - DBaaS'
    lan: test_lan1
  display_name: backuptest-04
  synchronization_mode: ASYNCHRONOUS
  db_username: clusteruser
  db_password: 7357cluster
  wait: true
register: cluster_response

Available parameters for state present:

NameRequiredDescription

maintenance_window dict

False

A weekly 4 hour-long window, during which maintenance might occur.

postgres_version str

True

The PostgreSQL version of your cluster.

instances int

True

The total number of instances in the cluster (one master and n-1 standbys).

cores int

True

The number of CPU cores per instance.

ram int

True

The amount of memory per instance in megabytes. Has to be a multiple of 1024.

storage_size int

True

The amount of storage per instance in megabytes.

storage_type str

True

The storage type used in your cluster. (Value "SSD" is deprecated. Use the equivalent "SSD Premium" instead) Options: ['HDD', 'SSD', 'SSD Standard', 'SSD Premium']

connections list

True

Array of datacenters to connect to your cluster.

location str

True

The physical location where the cluster will be created. This will be where all of your instances live. Property cannot be modified after datacenter creation.

display_name str

True

The friendly name of your cluster.

db_username str

True

The username for the initial PostgreSQL user. Some system usernames are restricted (e.g. "postgres", "admin", "standby").

db_password str

True

The password for the initial postgres user.

synchronization_mode str

True

Represents different modes of replication.

backup_location str

False

The S3 location where the backups will be stored.

backup_id str

False

The ID of the backup to be used.

recovery_target_time str

False

Recovery target time.

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

  
name: Delete Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
  postgres_cluster: ''
  state: absent
  wait: false

Available parameters for state absent:

NameRequiredDescription

postgres_cluster str

True

The ID or name of an existing Postgres Cluster.

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

  
name: Update Cluster
ionoscloudsdk.ionoscloud.postgres_cluster:
  postgres_cluster: ''
  instances: 2
  cores: 2
  ram: 4096
  storage_size: 30480
  state: update
  wait: true
register: updated_cluster_response

Available parameters for state update:

NameRequiredDescription

maintenance_window dict

False

A weekly 4 hour-long window, during which maintenance might occur.

postgres_version str

False

The PostgreSQL version of your cluster.

instances int

False

The total number of instances in the cluster (one master and n-1 standbys).

cores int

False

The number of CPU cores per instance.

ram int

False

The amount of memory per instance in megabytes. Has to be a multiple of 1024.

storage_size int

False

The amount of storage per instance in megabytes.

display_name str

False

The friendly name of your cluster.

postgres_cluster str

True

The ID or name of an existing Postgres Cluster.

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:

NameRequiredDescription

backup_id str

True

The ID of the backup to be used.

recovery_target_time str

False

Recovery target time.

postgres_cluster str

True

The ID or name of an existing Postgres Cluster.

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