fix config override check

This commit is contained in:
ace 2024-09-29 04:44:11 +03:00
parent d6457d12da
commit 42ecb387b6
Signed by: ace
GPG Key ID: 2C08973DD37A76FD
2 changed files with 20 additions and 12 deletions

View File

@ -60,10 +60,13 @@
when: sysctl_result.changed
- name: Apply default config
when:
- haproxy_config_override is not defined or haproxy_config_override | length <= 0
- haproxy_config_base64_override is not defined or haproxy_config_base64_override | length <= 0
block:
- name: Merge config for HAProxy
set_fact:
haproxy_combined_config: "{{ haproxy_config | default({}) | combine(haproxy_default_config, recursive=true) }}"
haproxy_combined_config: "{{ haproxy_default_config | combine(haproxy_config | default({}), recursive=true) }}"
- name: Add HAProxy config
template:
@ -71,11 +74,11 @@
dest: "/etc/haproxy/haproxy.cfg"
notify:
- Reload HAProxy
when:
- haproxy_config_override is not defined
- haproxy_config_base64_override is not defined
- name: Override with config in plain text
when:
- haproxy_config_override is defined
- haproxy_config_override | length > 0
block:
- set_fact:
haproxy_config: "{{ haproxy_config_override }}"
@ -86,9 +89,11 @@
dest: "/etc/haproxy/haproxy.cfg"
notify:
- Reload HAProxy
when: haproxy_config_override is defined
- name: Override with base64 config
when:
- haproxy_config_base64_override is defined
- haproxy_config_base64_override | length > 0
block:
- set_fact:
haproxy_config: "{{ haproxy_config_base64_override | b64decode }}"
@ -99,7 +104,6 @@
dest: "/etc/haproxy/haproxy.cfg"
notify:
- Reload HAProxy
when: haproxy_config_base64_override is defined
- name: Add maps for HAProxy
include_tasks: map.yaml

View File

@ -68,10 +68,13 @@
when: sysctl_result.changed
- name: Apply default config
when:
- haproxy_config_override is not defined or haproxy_config_override | length <= 0
- haproxy_config_base64_override is not defined or haproxy_config_base64_override | length <= 0
block:
- name: Merge config for HAProxy
set_fact:
haproxy_combined_config: "{{ haproxy_config | default({}) | combine(haproxy_default_config, recursive=true) }}"
haproxy_combined_config: "{{ haproxy_default_config | combine(haproxy_config | default({}), recursive=true) }}"
- name: Add HAProxy config
template:
@ -79,11 +82,11 @@
dest: "/etc/haproxy/haproxy.cfg"
notify:
- Reload HAProxy
when:
- haproxy_config_override is not defined
- haproxy_config_base64_override is not defined
- name: Override with config in plain text
when:
- haproxy_config_override is defined
- haproxy_config_override | length > 0
block:
- set_fact:
haproxy_config: "{{ haproxy_config_override }}"
@ -94,9 +97,11 @@
dest: "/etc/haproxy/haproxy.cfg"
notify:
- Reload HAProxy
when: haproxy_config_override is defined
- name: Override with base64 config
when:
- haproxy_config_base64_override is defined
- haproxy_config_base64_override | length > 0
block:
- set_fact:
haproxy_config: "{{ haproxy_config_base64_override | b64decode }}"
@ -107,7 +112,6 @@
dest: "/etc/haproxy/haproxy.cfg"
notify:
- Reload HAProxy
when: haproxy_config_base64_override is defined
- name: Add maps for HAProxy
include_tasks: map.yaml