diff --git a/tasks/Debian.yaml b/tasks/Debian.yaml index dca449e..5eff797 100644 --- a/tasks/Debian.yaml +++ b/tasks/Debian.yaml @@ -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 diff --git a/tasks/RedHat.yaml b/tasks/RedHat.yaml index b2699bb..273ccb1 100644 --- a/tasks/RedHat.yaml +++ b/tasks/RedHat.yaml @@ -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