Fix non-lazy ternery expression

The ansible 'ternery' filter is not a real (lazy) ternery operator meaning that
both branches are evaluated regardless of the input. Prior to this patch, this
would erroneously result in a crash if 'interface' was not specified.

Also includes unrelated linter-requested whitespace changes.

Change-Id: I483550527b37276a7742ca116b7366bbd0b05875
This commit is contained in:
Jonathan Heathcote
2025-02-07 12:17:33 +00:00
parent c001f16542
commit d138ff74e8

View File

@@ -64,13 +64,13 @@
dest: >-
{{
haproxy_ssl_cert_path ~ '/haproxy_' ~ ansible_facts['hostname'] ~ '-' ~ (item.get('interface')) | ternary(
item.get('address') ~ '-' ~ item['interface'], item['address']) ~ '.pem'
item.get('address') ~ '-' ~ item.get('interface'), item['address']) ~ '.pem'
}}
regexp: '(privkey|fullchain).pem$'
owner: haproxy
group: haproxy
mode: "0640"
with_items:
- "{{ haproxy_vip_binds | selectattr('type', 'defined') | selectattr('type', 'eq', 'external') }}"
- "{{ haproxy_vip_binds | selectattr('type', 'defined') | selectattr('type', 'eq', 'external') }}"
notify:
- Reload haproxy