Skip to content

Commit 4a61aab

Browse files
committed
Refactor DigitalOcean Spaces region handling
Updated region selection logic to use 'nyc3' for 'nyc1' and 'nyc2' server locations in cloud_resources, pgbackrest, and wal_g roles.
1 parent 85d9c9a commit 4a61aab

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

automation/roles/cloud_resources/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ azure_blob_storage_absent: false # Allow to delete Azure Blob Storage when delet
6262

6363
digital_ocean_spaces_create: true # if 'cloud_provider=digitalocean'
6464
digital_ocean_spaces_name: "{{ patroni_cluster_name }}-backup" # Name of the Spaces Object Storage (S3 bucket).
65-
digital_ocean_spaces_region: "nyc3" # The region to create the Space in.
65+
digital_ocean_spaces_region: "{{ (server_location in ['nyc1', 'nyc2']) | ternary('nyc3', server_location) }}" # The region to create the Space in.
6666
digital_ocean_spaces_access_key: "" # (required) Spaces Object Storage ACCESS KEY
6767
digital_ocean_spaces_secret_key: "" # (required) Spaces Object Storage SECRET KEY
6868
digital_ocean_spaces_absent: false # Allow to delete Spaces Object Storage when deleting a cluster servers using the 'state=absent' variable.

automation/roles/pgbackrest/tasks/auto_conf.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@
158158
- { option: "repo1-s3-bucket", value: "{{ pgbackrest_s3_bucket | default(digital_ocean_spaces_name | default(patroni_cluster_name + '-backup')) }}" }
159159
- {
160160
option: "repo1-s3-endpoint",
161-
value: "{{ pgbackrest_s3_endpoint | default('https://' + (digital_ocean_spaces_region | default(server_location)) + '.digitaloceanspaces.com') }}",
161+
value: "{{ pgbackrest_s3_endpoint | default('https://' + (digital_ocean_spaces_region | default(default_region)) + '.digitaloceanspaces.com') }}",
162162
}
163-
- { option: "repo1-s3-region", value: "{{ pgbackrest_s3_region | default(digital_ocean_spaces_region | default(server_location)) }}" }
163+
- { option: "repo1-s3-region", value: "{{ pgbackrest_s3_region | default(digital_ocean_spaces_region | default(default_region)) }}" }
164164
- { option: "repo1-s3-uri-style", value: "{{ pgbackrest_s3_uri_style | default('path') }}" }
165165
- { option: "repo1-retention-full", value: "{{ pgbackrest_retention_full | default('4') }}" }
166166
- { option: "repo1-retention-archive", value: "{{ pgbackrest_retention_archive | default('4') }}" }
@@ -180,6 +180,8 @@
180180
- { option: "log-level-console", value: "info" }
181181
- { option: "recovery-option", value: "recovery_target_action=promote" }
182182
- { option: "pg1-path", value: "{{ postgresql_data_dir }}" }
183+
vars:
184+
default_region: "{{ (server_location in ['nyc1', 'nyc2']) | ternary('nyc3', server_location) }}"
183185
no_log: true # do not output contents to the ansible log
184186
when: cloud_provider | default('') | lower == 'digitalocean'
185187

automation/roles/wal_g/tasks/auto_conf.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@
110110
- { option: "AWS_SECRET_ACCESS_KEY", value: "{{ wal_g_aws_secret_access_key | default(digital_ocean_spaces_secret_key | default(AWS_SECRET_ACCESS_KEY | default(''))) }}" }
111111
- {
112112
option: "AWS_ENDPOINT",
113-
value: "{{ wal_g_s3_endpoint | default('https://' + (digital_ocean_spaces_region | default(server_location)) + '.digitaloceanspaces.com') }}",
113+
value: "{{ wal_g_s3_endpoint | default('https://' + (digital_ocean_spaces_region | default(default_region)) + '.digitaloceanspaces.com') }}",
114114
}
115-
- { option: "AWS_REGION", value: "{{ wal_g_s3_region | default(digital_ocean_spaces_region | default(server_location)) }}" }
115+
- { option: "AWS_REGION", value: "{{ wal_g_s3_region | default(digital_ocean_spaces_region | default(default_region)) }}" }
116116
- { option: "AWS_S3_FORCE_PATH_STYLE", value: "{{ AWS_S3_FORCE_PATH_STYLE | default(true) }}" }
117117
- { option: "WALG_S3_PREFIX", value: "{{ wal_g_s3_prefix | default('s3://' + (digital_ocean_spaces_name | default(patroni_cluster_name + '-backup'))) }}" }
118118
- { option: "WALG_COMPRESSION_METHOD", value: "{{ wal_g_compression_method | default('brotli') }}" }
@@ -125,6 +125,8 @@
125125
- { option: "PGHOST", value: "{{ postgresql_unix_socket_dir | default('/var/run/postgresql') }}" }
126126
- { option: "PGPORT", value: "{{ postgresql_port | default('5432') }}" }
127127
- { option: "PGUSER", value: "{{ patroni_superuser_username | default('postgres') }}" }
128+
vars:
129+
default_region: "{{ (server_location in ['nyc1', 'nyc2']) | ternary('nyc3', server_location) }}"
128130
no_log: true # do not output contents to the ansible log
129131
when: cloud_provider | default('') | lower == 'digitalocean'
130132

0 commit comments

Comments
 (0)