Skip to content

Commit

Permalink
Rename "provision" to "cloud_provider"
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks committed Dec 18, 2023
1 parent e8dd09b commit bb2252e
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion config_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
tags: always
roles:
- role: cloud-resources
when: provision | lower != 'none'
when: cloud_provider | default('') | length > 0
tags: always

- name: config_pgcluster.yml | Check the PostgreSQL cluster state and perform pre-checks
Expand Down
2 changes: 1 addition & 1 deletion deploy_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
tags: always
roles:
- role: cloud-resources
when: provision | lower != 'none'
when: cloud_provider | default('') | length > 0
tags: always

- name: deploy_pgcluster.yml | Perform pre-checks
Expand Down
10 changes: 5 additions & 5 deletions roles/cloud-resources/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yamllint disable rule:line-length
---

provision: none # Platform for server creation. Available options: 'aws', 'gcp', 'azure', 'digitalocean', 'hetzner'. Default: none (do not create).
cloud_provider: "{{ provision | default('') }}" # Specifies the Cloud provider for server creation. Available options: 'aws', 'gcp', 'azure', 'digitalocean', 'hetzner'.
state: present # Set to 'present' to create a server, 'absent' to delete.

servers_count: 3 # Number of servers in the cluster. Servers will be automatically named with suffixes 01, 02, 03, etc.
Expand Down Expand Up @@ -31,26 +31,26 @@ database_public_access: false # Allow access to the database from the public ne
database_public_allowed_ips: "" # (comma-separated list of IP addresses in CIDR format) If empty, then public access is allowed for any IP address.

# Backups (if 'pgbackrest_install' or 'wal_g_install' is 'true')
aws_s3_bucket_create: true # if 'provision=aws'
aws_s3_bucket_create: true # if 'cloud_provider=aws'
aws_s3_bucket_name: "backups-{{ patroni_cluster_name }}" # Name of the S3 bucket. Bucket naming rules: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
aws_s3_bucket_region: "{{ server_location }}" # The AWS region to use.
aws_s3_bucket_object_lock_enabled: false # Whether S3 Object Lock to be enabled.
aws_s3_bucket_encryption: "AES256" # Describes the default server-side encryption to apply to new objects in the bucket. Choices: "AES256", "aws:kms"
aws_s3_bucket_absent: false # Allow to delete S3 bucket when deleting a cluster servers using the 'state=absent' variable.

gcp_bucket_create: true # if 'provision=gcp'
gcp_bucket_create: true # if 'cloud_provider=gcp'
gcp_bucket_name: "backups-{{ patroni_cluster_name }}" # Name of the GCS bucket.
gcp_bucket_storage_class: "MULTI_REGIONAL" # The bucket’s default storage class. Values include: MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, ARCHIVE, DURABLE_REDUCED_AVAILABILITY.
gcp_bucket_default_object_acl: "projectPrivate" # Apply a predefined set of default object access controls to this bucket.
gcp_bucket_absent: false # Allow to delete GCS bucket when deleting a cluster servers using the 'state=absent' variable.

azure_blob_storage_create: true # if 'provision=azure'
azure_blob_storage_create: true # if 'cloud_provider=azure'
azure_blob_storage_name: "backups-{{ patroni_cluster_name }}" # Name of a blob container within the storage account.
azure_blob_storage_account_name: "{{ patroni_cluster_name | lower | replace('-', '') | truncate(24, true, '') }}" # Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.
azure_blob_storage_account_type: "Standard_RAGRS" # Type of storage account. Values include: Standard_LRS, Standard_GRS, Standard_RAGRS, Standard_ZRS, Standard_RAGZRS, Standard_GZRS, Premium_LRS, Premium_ZRS.
azure_blob_storage_absent: false # Allow to delete Azure Blob Storage when deleting a cluster servers using the 'state=absent' variable.

digital_ocean_spaces_create: true # if 'provision=digitalocean'
digital_ocean_spaces_create: true # if 'cloud_provider=digitalocean'
digital_ocean_spaces_name: "backups-{{ patroni_cluster_name | lower }}" # Name of the Spaces Object Storage (S3 bucket).
digital_ocean_spaces_region: "nyc3" # The region to create the Space in.
digital_ocean_spaces_absent: false # Allow to delete Spaces Object Storage when deleting a cluster servers using the 'state=absent' variable.
Expand Down
12 changes: 6 additions & 6 deletions roles/cloud-resources/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- "Please specify value for variables: 'server_type', 'server_image', 'server_location', 'volume_size'."
when: state == 'present' and
(server_type | length < 1 or
(server_image | length < 1 and provision != 'azure') or
(server_image | length < 1 and cloud_provider != 'azure') or
server_location | length < 1 or
volume_size | length < 1)

Expand Down Expand Up @@ -43,22 +43,22 @@

- name: Import tasks for AWS
ansible.builtin.import_tasks: aws.yml
when: provision | lower == 'aws'
when: cloud_provider | lower == 'aws'

- name: Import tasks for GCP
ansible.builtin.import_tasks: gcp.yml
when: provision | lower == 'gcp'
when: cloud_provider | lower == 'gcp'

- name: Import tasks for Azure
ansible.builtin.import_tasks: azure.yml
when: provision | lower == 'azure'
when: cloud_provider | lower == 'azure'

- name: Import tasks for DigitalOcean
ansible.builtin.import_tasks: digitalocean.yml
when: provision | lower in ['digitalocean', 'do']
when: cloud_provider | lower in ['digitalocean', 'do']

- name: Import tasks for Hetzner Cloud
ansible.builtin.import_tasks: hetzner.yml
when: provision | lower == 'hetzner'
when: cloud_provider | lower == 'hetzner'

...
4 changes: 2 additions & 2 deletions roles/mount/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- block:
# Try to detect an empty disk (if provision != 'none')
# Try to detect an empty disk (if 'cloud_provider' is defined)
- name: Detect empty volume
ansible.builtin.shell: |
set -o pipefail;
Expand All @@ -11,7 +11,7 @@
executable: /bin/bash
register: lsblk_disk
changed_when: false
when: (provision is defined and provision | lower != 'none') and mount[0].src | length < 1
when: (cloud_provider | default('') | length > 0) and mount[0].src | length < 1

# Show the error message, if empty volume is not detected
- name: Empty volume is not detected
Expand Down
16 changes: 8 additions & 8 deletions roles/pgbackrest/tasks/auto_conf.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yamllint disable rule:line-length
---

# AWS S3 bucket (if 'provision=aws')
# AWS S3 bucket (if 'cloud_provider=aws')
- name: "Set variable 'pgbackrest_conf' for backup in AWS S3 bucket"
ansible.builtin.set_fact:
pgbackrest_conf:
Expand Down Expand Up @@ -33,9 +33,9 @@
- { option: "recovery-option", value: "recovery_target_action=promote" }
- { option: "pg1-path", value: "{{ pg_data_mount_path | default('/pgdata') }}/{{ postgresql_version }}/{{ patroni_cluster_name }}" }
no_log: true # do not output contents to the ansible log
when: provision | default('') | lower == 'aws'
when: cloud_provider | default('') | lower == 'aws'

# GCS Bucket (if 'provision=gcp')
# GCS Bucket (if 'cloud_provider=gcp')
- block:
- name: "Set variable 'pgbackrest_conf' for backup in GCS Bucket"
ansible.builtin.set_fact:
Expand Down Expand Up @@ -95,9 +95,9 @@
group: "postgres"
no_log: true # do not output GCP service account contents to the ansible log
when: gcs_key_file is defined and gcs_key_file | length > 0
when: provision | default('') | lower == 'gcp'
when: cloud_provider | default('') | lower == 'gcp'

# Azure Blob Storage (if 'provision=azure')
# Azure Blob Storage (if 'cloud_provider=azure')
- name: "Set variable 'pgbackrest_conf' for backup in Azure Blob Storage"
ansible.builtin.set_fact:
pgbackrest_conf:
Expand Down Expand Up @@ -128,9 +128,9 @@
- { option: "recovery-option", value: "recovery_target_action=promote" }
- { option: "pg1-path", value: "{{ pg_data_mount_path | default('/pgdata') }}/{{ postgresql_version }}/{{ patroni_cluster_name }}" }
no_log: true # do not output contents to the ansible log
when: provision | default('') | lower == 'azure'
when: cloud_provider | default('') | lower == 'azure'

# DigitalOcean Spaces Object Storage (if 'provision=digitalocean')
# DigitalOcean Spaces Object Storage (if 'cloud_provider=digitalocean')
- name: "Set variable 'pgbackrest_conf' for backup in DigitalOcean Spaces Object Storage"
ansible.builtin.set_fact:
pgbackrest_conf:
Expand Down Expand Up @@ -163,6 +163,6 @@
- { option: "recovery-option", value: "recovery_target_action=promote" }
- { option: "pg1-path", value: "{{ pg_data_mount_path | default('/pgdata') }}/{{ postgresql_version }}/{{ patroni_cluster_name }}" }
no_log: true # do not output contents to the ansible log
when: provision | default('') | lower == 'digitalocean'
when: cloud_provider | default('') | lower == 'digitalocean'

...
4 changes: 2 additions & 2 deletions roles/pgbackrest/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---

# Automatic setup of the backup configuration based on the selected cloud provider.
# if 'provision' is 'aws', 'gcp', 'azure', 'digitalocean'.
# if 'cloud_provider' is 'aws', 'gcp', 'azure', 'digitalocean'.
- ansible.builtin.import_tasks: auto_conf.yml
when: provision | default('none') != 'none'
when: cloud_provider | default('') | length > 0
tags: pgbackrest, pgbackrest_conf

- block: # Debian pgdg repo
Expand Down
16 changes: 8 additions & 8 deletions roles/wal-g/tasks/auto_conf.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yamllint disable rule:line-length
---

# AWS S3 bucket (if 'provision=aws')
# AWS S3 bucket (if 'cloud_provider=aws')
- name: "Set variable 'wal_g_json' for backup in AWS S3 bucket"
ansible.builtin.set_fact:
wal_g_json:
Expand All @@ -19,9 +19,9 @@
- { option: "PGPORT", value: "{{ postgresql_port | default('5432') }}" }
- { option: "PGUSER", value: "{{ patroni_superuser_username | default('postgres') }}" }
no_log: true # do not output contents to the ansible log
when: provision | default('') | lower == 'aws'
when: cloud_provider | default('') | lower == 'aws'

# GCS Bucket (if 'provision=gcp')
# GCS Bucket (if 'cloud_provider=gcp')
- block:
- name: "Set variable 'wal_g_json' for backup in GCS Bucket"
ansible.builtin.set_fact:
Expand Down Expand Up @@ -68,9 +68,9 @@
group: "postgres"
no_log: true # do not output GCP service account contents to the ansible log
when: gcs_key_file is defined and gcs_key_file | length > 0
when: provision | default('') | lower == 'gcp'
when: cloud_provider | default('') | lower == 'gcp'

# Azure Blob Storage (if 'provision=azure')
# Azure Blob Storage (if 'cloud_provider=azure')
- name: "Set variable 'wal_g_json' for backup in Azure Blob Storage"
ansible.builtin.set_fact:
wal_g_json:
Expand All @@ -87,9 +87,9 @@
- { option: "PGPORT", value: "{{ postgresql_port | default('5432') }}" }
- { option: "PGUSER", value: "{{ patroni_superuser_username | default('postgres') }}" }
no_log: true # do not output contents to the ansible log
when: provision | default('') | lower == 'azure'
when: cloud_provider | default('') | lower == 'azure'

# DigitalOcean Spaces Object Storage (if 'provision=digitalocean')
# DigitalOcean Spaces Object Storage (if 'cloud_provider=digitalocean')
- name: "Set variable 'wal_g_json' for backup in DigitalOcean Spaces Object Storage"
ansible.builtin.set_fact:
wal_g_json:
Expand All @@ -109,6 +109,6 @@
- { option: "PGPORT", value: "{{ postgresql_port | default('5432') }}" }
- { option: "PGUSER", value: "{{ patroni_superuser_username | default('postgres') }}" }
no_log: true # do not output contents to the ansible log
when: provision | default('') | lower == 'digitalocean'
when: cloud_provider | default('') | lower == 'digitalocean'

...
4 changes: 2 additions & 2 deletions roles/wal-g/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---

# Automatic setup of the backup configuration based on the selected cloud provider.
# if 'provision' is 'aws', 'gcp', 'azure', 'digitalocean'.
# if 'cloud_provider' is 'aws', 'gcp', 'azure', 'digitalocean'.
- ansible.builtin.import_tasks: auto_conf.yml
when: provision | default('none') != 'none'
when: cloud_provider | default('') | length > 0
tags: wal-g, wal_g, wal_g_conf

- name: Check if WAL-G is already installed
Expand Down
4 changes: 2 additions & 2 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# PostgreSQL variables
postgresql_cluster_name: "\
{% if provision is defined and provision | lower != 'none' %}\
{% if cloud_provider | default('') | length > 0 %}\
{{ patroni_cluster_name }}\
{% else %}\
main\
Expand All @@ -12,7 +12,7 @@ postgresql_cluster_name: "\
# along the path defined in the 'pg_data_mount_path' variable (or use '/pgdata' by default).
# You can specify custom data dir path. Example: "/pgdata/{{ postgresql_version }}/{{ postgresql_cluster_name }}"
postgresql_data_dir: "\
{% if provision is defined and provision | lower != 'none' %}\
{% if cloud_provider | default('') | length > 0 %}\
{{ pg_data_mount_path | default('/pgdata') }}/{{ postgresql_version }}/{{ postgresql_cluster_name }}\
{% else %}\
/var/lib/postgresql/{{ postgresql_version }}/{{ postgresql_cluster_name }}\
Expand Down
2 changes: 1 addition & 1 deletion vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# along the path defined in the 'pg_data_mount_path' variable (or use '/pgdata' by default).
# You can specify custom data dir path. Example: "/pgdata/{{ postgresql_version }}/{{ patroni_cluster_name }}"
postgresql_data_dir: "\
{% if provision is defined and provision | lower != 'none' %}\
{% if cloud_provider | default('') | length > 0 %}\
{{ pg_data_mount_path | default('/pgdata') }}/{{ postgresql_version }}/{{ patroni_cluster_name }}\
{% else %}\
/var/lib/pgsql/{{ postgresql_version }}/data\
Expand Down

0 comments on commit bb2252e

Please sign in to comment.