mirror of
https://gitea.0xace.cc/ansible-galaxy/haproxy.git
synced 2024-11-24 16:06:40 +00:00
Don't override haproxy.cfg if it is manageabled by haproxy data plane api
This commit is contained in:
parent
42ecb387b6
commit
daa1b0d01f
@ -6,10 +6,13 @@ haproxy_cert_name: haproxy.pem
|
|||||||
haproxy_self_signed_cert: no
|
haproxy_self_signed_cert: no
|
||||||
haproxy_self_signed_cert_gen_path: "{{ haproxy_path }}/tempssl"
|
haproxy_self_signed_cert_gen_path: "{{ haproxy_path }}/tempssl"
|
||||||
haproxy_lua_path: "{{ haproxy_path }}/lua"
|
haproxy_lua_path: "{{ haproxy_path }}/lua"
|
||||||
|
haproxy_maps_path: "{{ haproxy_path }}/maps"
|
||||||
|
|
||||||
haproxy_stats_user: haproxy
|
haproxy_stats_user: haproxy
|
||||||
haproxy_stats_password: P@ssw0rd
|
haproxy_stats_password: P@ssw0rd
|
||||||
|
|
||||||
|
haproxy_dataplaneapi: false
|
||||||
|
|
||||||
haproxy_default_config:
|
haproxy_default_config:
|
||||||
global:
|
global:
|
||||||
daemon:
|
daemon:
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
when:
|
when:
|
||||||
- haproxy_config_override is not defined or haproxy_config_override | length <= 0
|
- 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
|
- haproxy_config_base64_override is not defined or haproxy_config_base64_override | length <= 0
|
||||||
|
- not haproxy_dataplaneapi or not haproxy_config_file_exists
|
||||||
block:
|
block:
|
||||||
- name: Merge config for HAProxy
|
- name: Merge config for HAProxy
|
||||||
set_fact:
|
set_fact:
|
||||||
@ -79,6 +80,7 @@
|
|||||||
when:
|
when:
|
||||||
- haproxy_config_override is defined
|
- haproxy_config_override is defined
|
||||||
- haproxy_config_override | length > 0
|
- haproxy_config_override | length > 0
|
||||||
|
- not haproxy_dataplaneapi or not haproxy_config_file_exists
|
||||||
block:
|
block:
|
||||||
- set_fact:
|
- set_fact:
|
||||||
haproxy_config: "{{ haproxy_config_override }}"
|
haproxy_config: "{{ haproxy_config_override }}"
|
||||||
@ -94,6 +96,7 @@
|
|||||||
when:
|
when:
|
||||||
- haproxy_config_base64_override is defined
|
- haproxy_config_base64_override is defined
|
||||||
- haproxy_config_base64_override | length > 0
|
- haproxy_config_base64_override | length > 0
|
||||||
|
- not haproxy_dataplaneapi or not haproxy_config_file_exists
|
||||||
block:
|
block:
|
||||||
- set_fact:
|
- set_fact:
|
||||||
haproxy_config: "{{ haproxy_config_base64_override | b64decode }}"
|
haproxy_config: "{{ haproxy_config_base64_override | b64decode }}"
|
||||||
@ -106,16 +109,19 @@
|
|||||||
- Reload HAProxy
|
- Reload HAProxy
|
||||||
|
|
||||||
- name: Add maps for HAProxy
|
- name: Add maps for HAProxy
|
||||||
include_tasks: map.yaml
|
include_tasks: maps.yaml
|
||||||
when: haproxy_map is defined
|
when:
|
||||||
|
- haproxy_maps is defined
|
||||||
|
|
||||||
- name: Add lua code for HAProxy
|
- name: Add lua code for HAProxy
|
||||||
include_tasks: lua.yaml
|
include_tasks: lua.yaml
|
||||||
when: haproxy_lua is defined
|
when:
|
||||||
|
- haproxy_lua is defined
|
||||||
|
|
||||||
- name: Add certificate for HAProxy
|
- name: Add certificate for HAProxy
|
||||||
include_tasks: cert.yaml
|
include_tasks: cert.yaml
|
||||||
when: haproxy_ssl
|
when:
|
||||||
|
- haproxy_ssl
|
||||||
|
|
||||||
- name: Enable and start HAProxy service
|
- name: Enable and start HAProxy service
|
||||||
systemd:
|
systemd:
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
when:
|
when:
|
||||||
- haproxy_config_override is not defined or haproxy_config_override | length <= 0
|
- 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
|
- haproxy_config_base64_override is not defined or haproxy_config_base64_override | length <= 0
|
||||||
|
- not haproxy_dataplaneapi or not haproxy_config_file_exists
|
||||||
block:
|
block:
|
||||||
- name: Merge config for HAProxy
|
- name: Merge config for HAProxy
|
||||||
set_fact:
|
set_fact:
|
||||||
@ -87,6 +88,7 @@
|
|||||||
when:
|
when:
|
||||||
- haproxy_config_override is defined
|
- haproxy_config_override is defined
|
||||||
- haproxy_config_override | length > 0
|
- haproxy_config_override | length > 0
|
||||||
|
- not haproxy_dataplaneapi or not haproxy_config_file_exists
|
||||||
block:
|
block:
|
||||||
- set_fact:
|
- set_fact:
|
||||||
haproxy_config: "{{ haproxy_config_override }}"
|
haproxy_config: "{{ haproxy_config_override }}"
|
||||||
@ -102,6 +104,7 @@
|
|||||||
when:
|
when:
|
||||||
- haproxy_config_base64_override is defined
|
- haproxy_config_base64_override is defined
|
||||||
- haproxy_config_base64_override | length > 0
|
- haproxy_config_base64_override | length > 0
|
||||||
|
- not haproxy_dataplaneapi or not haproxy_config_file_exists
|
||||||
block:
|
block:
|
||||||
- set_fact:
|
- set_fact:
|
||||||
haproxy_config: "{{ haproxy_config_base64_override | b64decode }}"
|
haproxy_config: "{{ haproxy_config_base64_override | b64decode }}"
|
||||||
@ -114,16 +117,19 @@
|
|||||||
- Reload HAProxy
|
- Reload HAProxy
|
||||||
|
|
||||||
- name: Add maps for HAProxy
|
- name: Add maps for HAProxy
|
||||||
include_tasks: map.yaml
|
include_tasks: maps.yaml
|
||||||
when: haproxy_map is defined
|
when:
|
||||||
|
- haproxy_maps is defined
|
||||||
|
|
||||||
- name: Add lua code for HAProxy
|
- name: Add lua code for HAProxy
|
||||||
include_tasks: lua.yaml
|
include_tasks: lua.yaml
|
||||||
when: haproxy_lua is defined
|
when:
|
||||||
|
- haproxy_lua is defined
|
||||||
|
|
||||||
- name: Add certificate for HAProxy
|
- name: Add certificate for HAProxy
|
||||||
include_tasks: cert.yaml
|
include_tasks: cert.yaml
|
||||||
when: haproxy_ssl
|
when:
|
||||||
|
- haproxy_ssl
|
||||||
|
|
||||||
- name: Enable and start HAProxy service
|
- name: Enable and start HAProxy service
|
||||||
systemd:
|
systemd:
|
||||||
|
@ -17,5 +17,8 @@
|
|||||||
- "vars"
|
- "vars"
|
||||||
tags: haproxy_vars
|
tags: haproxy_vars
|
||||||
|
|
||||||
|
- name: Include pre-checks.yaml
|
||||||
|
include_tasks: pre-checks.yaml
|
||||||
|
|
||||||
- name: Include HAProxy install
|
- name: Include HAProxy install
|
||||||
include_tasks: "{{ ansible_facts['os_family'] }}.yaml"
|
include_tasks: "{{ ansible_facts['os_family'] }}.yaml"
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Write maps for HAProxy
|
|
||||||
copy:
|
|
||||||
dest: "{{ haproxy_path }}/{{ item.key }}"
|
|
||||||
content: "{{ item.value }}"
|
|
||||||
loop: "{{ haproxy_map | dict2items }}"
|
|
||||||
notify:
|
|
||||||
- Reload HAProxy
|
|
13
tasks/maps.yaml
Normal file
13
tasks/maps.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
- name: Create maps dir for HAProxy
|
||||||
|
file:
|
||||||
|
path: "{{ haproxy_maps_path }}"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Write maps for HAProxy
|
||||||
|
copy:
|
||||||
|
dest: "{{ haproxy_maps_path }}/{{ item.key }}"
|
||||||
|
content: "{{ item.value }}"
|
||||||
|
loop: "{{ haproxy_map | dict2items }}"
|
||||||
|
notify:
|
||||||
|
- Reload HAProxy
|
8
tasks/pre-checks.yaml
Normal file
8
tasks/pre-checks.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
- name: Check if haproxy.cfg exists
|
||||||
|
stat:
|
||||||
|
path: "/etc/haproxy/haproxy.cfg"
|
||||||
|
register: haproxy_config_file_exists_result
|
||||||
|
|
||||||
|
- name: Set fact about existing haproxy.cfg
|
||||||
|
set_fact:
|
||||||
|
haproxy_config_file_exists: "{{ true if haproxy_config_file_exists_result.stat.exists else false }}"
|
Loading…
Reference in New Issue
Block a user