Skip to content

Commit d42816f

Browse files
committed
Merge remote-tracking branch 'origin/expert-mode' into expert-mode
2 parents 082f441 + e09661a commit d42816f

File tree

18 files changed

+71
-57
lines changed

18 files changed

+71
-57
lines changed

automation/inventory.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
# if dcs_exists: false and dcs_type: "consul"
1818
[consul_instances] # recommendation: 3 or 5-7 nodes
19-
#10.128.64.140 consul_node_role=server consul_bootstrap_expect=true consul_datacenter=dc1
20-
#10.128.64.142 consul_node_role=server consul_bootstrap_expect=true consul_datacenter=dc1
21-
#10.128.64.143 consul_node_role=server consul_bootstrap_expect=true consul_datacenter=dc1
19+
#10.128.64.140 consul_node_role=server consul_datacenter=dc1
20+
#10.128.64.142 consul_node_role=server consul_datacenter=dc1
21+
#10.128.64.143 consul_node_role=server consul_datacenter=dc1
2222
#10.128.64.144 consul_node_role=client consul_datacenter=dc2
2323
#10.128.64.145 consul_node_role=client consul_datacenter=dc2
2424

automation/molecule/default/converge.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
dcs_type: "{{ 'etcd' if ansible_distribution_major_version in ['10'] or ansible_distribution_release in ['trixie']
1818
else (['etcd', 'consul'] | random) }}" # TODO: Consul support for RHEL 10, Debian 13
1919
consul_node_role: server # if dcs_type: "consul"
20-
consul_bootstrap_expect: true # if dcs_type: "consul"
2120
postgresql_version: 18
2221
pgbouncer_processes: 2 # Test multiple pgbouncer processes (so_reuseport)
2322
patroni_tags: "datacenter=dc1,key1=value1"

automation/molecule/pg_upgrade/converge.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
dcs_type: "{{ 'etcd' if ansible_distribution_major_version in ['10'] or ansible_distribution_release in ['trixie']
1818
else (['etcd', 'consul'] | random) }}" # TODO: Consul support for RHEL 10, Debian 13
1919
consul_node_role: server # if dcs_type: "consul"
20-
consul_bootstrap_expect: true # if dcs_type: "consul"
2120
postgresql_version: 17 # redefine the version to install for the upgrade test
2221
pgbouncer_processes: 4 # Test multiple pgbouncer processes (so_reuseport)
2322
cacheable: true

automation/playbooks/consul_cluster.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,6 @@
148148
consul_dnsmasq_servers: "{{ consul_dnsmasq_servers | reject('equalto', '127.0.0.1') | list }}"
149149
when: dcs_type | default('etcd') == "consul" and consul_dnsmasq_enable | default(true) | bool and ('127.0.0.1' in (consul_dnsmasq_servers | default([])))
150150

151-
# Setting variables for Consul during cloud deployment
152-
- name: Redefine the consul_node_role and consul_bootstrap_expect variables
153-
ansible.builtin.set_fact:
154-
consul_node_role: "{{ 'server' if not dcs_exists | default(false) else 'client' }}"
155-
consul_bootstrap_expect: "{{ not dcs_exists | default(false) }}"
156-
consul_datacenter: "{{ server_location | default('dc1') }}"
157-
when: cloud_provider | default('') | length > 0
158-
159151
roles:
160152
- role: vitabaks.autobase.firewall
161153
vars:

automation/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ansible==12.1.0
2-
boto3==1.40.61
1+
ansible==12.2.0
2+
boto3==1.40.74
33
dopy==0.3.7
4-
google-auth==2.42.0
5-
hcloud==2.9.0
4+
google-auth==2.43.0
5+
hcloud==2.11.1

automation/requirements.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
22
collections:
33
- name: amazon.aws
4-
version: ">=10.1.1"
4+
version: ">=10.1.2"
55
- name: community.aws
66
version: ">=10.0.0"
77
- name: google.cloud
8-
version: ">=1.8.0"
8+
version: ">=1.10.2"
99
- name: azure.azcollection
10-
version: ">=3.8.0"
10+
version: ">=3.10.1"
1111
- name: community.digitalocean
1212
version: ">=1.27.0"
1313
- name: hetzner.hcloud
14-
version: ">=5.2.0"
14+
version: ">=5.4.0"
1515
- name: community.postgresql
16-
version: ">=3.14.2"
16+
version: ">=4.1.0"
1717
- name: community.docker
18-
version: ">=4.6.1"
18+
version: ">=4.8.2"
1919
- name: community.general
20-
version: ">=10.7.2"
20+
version: ">=11.4.1"
2121
- name: ansible.posix
22-
version: ">=1.6.2"
22+
version: ">=2.1.0"
2323
- name: ansible.utils
24-
version: ">=5.1.2"
24+
version: ">=6.0.0"

automation/roles/cloud_resources/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ 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.
6969

7070
hetzner_object_storage_create: true # if 'cloud_provider=hetzner'
7171
hetzner_object_storage_name: "{{ patroni_cluster_name }}-backup" # Name of the Object Storage (S3 bucket).
72-
hetzner_object_storage_region: "{{ server_location }}" # The region where the Object Storage (S3 bucket) will be created.
72+
hetzner_object_storage_region: "{{ (server_location in ['hel1', 'fsn1', 'nbg1']) | ternary(server_location, 'nbg1') }}" # The region where the Object Storage (S3 bucket) will be created.
7373
hetzner_object_storage_endpoint: "https://{{ hetzner_object_storage_region }}.your-objectstorage.com"
7474
hetzner_object_storage_access_key: "" # (required) Object Storage ACCESS KEY
7575
hetzner_object_storage_secret_key: "" # (required) Object Storage SECRET KEY

automation/roles/cloud_resources/tasks/digitalocean.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@
143143
ansible.builtin.set_fact:
144144
default_ip_range: >-
145145
{{
146-
vpc_info.data
146+
vpc_info.get('data', [])
147147
| selectattr('region', 'equalto', server_location)
148148
| selectattr('default', 'equalto', true)
149149
| map(attribute='ip_range')
150150
| first
151151
}}
152152
when:
153153
- server_network | length < 1
154-
- vpc_info.data | selectattr('region', 'equalto', server_location) | selectattr('default', 'equalto', true) | list | length > 0
154+
- vpc_info.get('data', []) | selectattr('region', 'equalto', server_location) | selectattr('default', 'equalto', true) | list | length > 0
155155

156156
# if server_network is not specified and there is no default VPC, create a network
157157
- name: "DigitalOcean: Create a VPC '{{ digital_ocean_vpc_name | default('network-' + server_location | default('')) }}'"
@@ -163,32 +163,41 @@
163163
register: digital_ocean_vpc
164164
when:
165165
- server_network | length < 1
166-
- vpc_info.data | selectattr('region', 'equalto', server_location) | selectattr('default', 'equalto', true) | list | length == 0
166+
- vpc_info.get('data', []) | selectattr('region', 'equalto', server_location) | selectattr('default', 'equalto', true) | list | length == 0
167167

168168
- name: "Set variable: server_network"
169169
ansible.builtin.set_fact:
170170
server_network: "{{ digital_ocean_vpc_name | default('network-' + server_location) }}"
171-
when: digital_ocean_vpc is changed
171+
when:
172+
- digital_ocean_vpc is defined
173+
- digital_ocean_vpc is changed
172174

173175
- name: "DigitalOcean: Gather information about VPC"
174176
community.digitalocean.digital_ocean_vpc_info:
175177
oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
176178
register: vpc_info
177-
when: digital_ocean_vpc is changed
179+
when:
180+
- digital_ocean_vpc is defined
181+
- digital_ocean_vpc is changed
178182

179183
# if server_network is specified
180184
- name: "Fail if no VPC found in the specified region"
181185
ansible.builtin.fail:
182186
msg: "No VPC found with name '{{ server_network }}' in region '{{ server_location }}'"
183187
when:
184188
- server_network | length > 0
185-
- vpc_info.data | selectattr('region', 'equalto', server_location) | selectattr('name', 'equalto', server_network) | list | length == 0
189+
- (vpc_info.get('data', [])
190+
| selectattr('region', 'equalto', server_location)
191+
| selectattr('name', 'equalto', server_network)
192+
| list
193+
| length
194+
) == 0
186195

187196
- name: Extract ip_range from VPC "{{ server_network | default('') }}"
188197
ansible.builtin.set_fact:
189198
vpc_ip_range: >-
190199
{{
191-
vpc_info.data
200+
vpc_info.get('data', [])
192201
| selectattr('region', 'equalto', server_location)
193202
| selectattr('name', 'equalto', server_network)
194203
| map(attribute='ip_range')
@@ -200,7 +209,7 @@
200209
ansible.builtin.set_fact:
201210
vpc_id: >-
202211
{{
203-
vpc_info.data
212+
vpc_info.get('data', [])
204213
| selectattr('region', 'equalto', server_location)
205214
| selectattr('name', 'equalto', server_network)
206215
| map(attribute='id')
@@ -620,9 +629,12 @@
620629
oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
621630
name: "{{ digital_ocean_spaces_name }}"
622631
region: "{{ digital_ocean_spaces_region }}"
623-
aws_access_key_id: "{{ AWS_ACCESS_KEY_ID }}"
624-
aws_secret_access_key: "{{ AWS_SECRET_ACCESS_KEY }}"
632+
aws_access_key_id: "{{ digital_ocean_spaces_access_key | default(AWS_ACCESS_KEY_ID | default(default_access_key), true) }}"
633+
aws_secret_access_key: "{{ digital_ocean_spaces_secret_key | default(AWS_SECRET_ACCESS_KEY | default(default_secret_key), true) }}"
625634
state: present
635+
vars:
636+
default_access_key: "{{ pgbackrest_s3_key | default(wal_g_aws_access_key_id | default('')) }}"
637+
default_secret_key: "{{ pgbackrest_s3_key_secret | default(wal_g_aws_secret_access_key | default('')) }}"
626638
when:
627639
- (pgbackrest_install | bool or wal_g_install | bool)
628640
- digital_ocean_spaces_create | bool

automation/roles/cloud_resources/tasks/hetzner.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,20 +448,21 @@
448448
amazon.aws.s3_bucket:
449449
endpoint_url: "{{ hetzner_object_storage_endpoint }}"
450450
ceph: true
451-
aws_access_key: "{{ hetzner_object_storage_access_key }}"
452-
aws_secret_key: "{{ hetzner_object_storage_secret_key }}"
451+
aws_access_key: "{{ hetzner_object_storage_access_key | default(default_access_key, true) }}"
452+
aws_secret_key: "{{ hetzner_object_storage_secret_key | default(default_secret_key, true) }}"
453453
name: "{{ hetzner_object_storage_name }}"
454454
region: "{{ hetzner_object_storage_region }}"
455455
requester_pays: false
456456
state: present
457457
register: s3_bucket_result
458458
failed_when: s3_bucket_result.failed and not "GetBucketRequestPayment" in s3_bucket_result.msg
459459
# TODO: https://github.com/ansible-collections/amazon.aws/issues/2447
460+
vars:
461+
default_access_key: "{{ pgbackrest_s3_key | default(wal_g_aws_access_key_id | default('')) }}"
462+
default_secret_key: "{{ pgbackrest_s3_key_secret | default(wal_g_aws_secret_access_key | default('')) }}"
460463
when:
461464
- (pgbackrest_install | bool or wal_g_install | bool)
462465
- hetzner_object_storage_create | bool
463-
- hetzner_object_storage_access_key | length > 0
464-
- hetzner_object_storage_secret_key | length > 0
465466

466467
# Server and volume
467468
- name: "Hetzner Cloud: Gather information about servers"

automation/roles/cloud_resources/tasks/inventory.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
ansible.builtin.add_host:
7979
name: "{{ item.private_ip }}"
8080
group: consul_instances
81+
consul_node_role: "{{ 'server' if not dcs_exists | default(false) else 'client' }}"
8182
ansible_ssh_host: "{{ item[server_public_ip | bool | ternary('public_ip', 'private_ip')] }}"
8283
ansible_ssh_private_key_file: "{{ ssh_private_key_file | default(None) }}"
8384
new_node: "{{ item.new_node | default(omit) }}"

0 commit comments

Comments
 (0)