Skip to content

Commit 3f1c771

Browse files
Copilotvitabaks
andcommitted
Update bind address selection logic to check variable existence and values
Co-authored-by: vitabaks <[email protected]>
1 parent 3de897d commit 3f1c771

File tree

1 file changed

+4
-6
lines changed
  • automation/roles/tls_certificate/tasks

1 file changed

+4
-6
lines changed

automation/roles/tls_certificate/tasks/main.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,14 @@
9494
}}
9595
tls_bind_address_var: >-
9696
{{
97-
'etcd_bind_address' if tls_group_name | default('') == 'etcd_cluster'
98-
else 'consul_bind_address' if tls_group_name | default('') == 'consul_instances'
99-
else 'patroni_bind_address' if tls_group_name | default('') == 'postgres_cluster'
97+
'etcd_bind_address' if (tls_group_name | default('') == 'etcd_cluster' and etcd_bind_address | default('') | length > 0)
98+
else 'consul_bind_address' if (tls_group_name | default('') == 'consul_instances' and consul_bind_address | default('') | length > 0)
99+
else 'patroni_bind_address' if (tls_group_name | default('') == 'postgres_cluster' and patroni_bind_address | default('') | length > 0)
100100
else 'bind_address'
101101
}}
102102
tls_bind_addresses: >-
103103
{{
104-
tls_hosts | map('extract', hostvars) |
105-
map('json_query', tls_bind_address_var + ' || bind_address') |
106-
select('string') | select('length') | list
104+
tls_hosts | map('extract', hostvars, tls_bind_address_var) | map('regex_replace', '^', 'IP:') | list
107105
}}
108106
when: tls_subject_alt_name | default('') | length < 1
109107

0 commit comments

Comments
 (0)