forked from evolix/ansible-roles
haproxy: simplify template selection
This commit is contained in:
parent
85d90e05f1
commit
597ae12dca
|
@ -12,3 +12,12 @@ Everything is in the `tasks/main.yml` file.
|
||||||
* `haproxy_package_release`: which Debian release to use for HAProxy (default: `general_package_release`).
|
* `haproxy_package_release`: which Debian release to use for HAProxy (default: `general_package_release`).
|
||||||
|
|
||||||
The full list of variables (with default values) can be found in `defaults/main.yml`.
|
The full list of variables (with default values) can be found in `defaults/main.yml`.
|
||||||
|
|
||||||
|
## Configuration templates
|
||||||
|
|
||||||
|
The roles compiles a `haproxy.cfg` file based on templates that are looked up in that order :
|
||||||
|
1. `{{ playbook_dir}}/templates/haproxy/haproxy.{{ inventory_hostname}}.cfg.j2`
|
||||||
|
2. `{{ playbook_dir}}/templates/haproxy/haproxy.{{ host_group}}.cfg.j2` (NB : `host_group` is not a core variable, it must be defined in `group_vars` files.)
|
||||||
|
3. `{{ playbook_dir}}/templates/haproxy/haproxy.default.cfg.j2`
|
||||||
|
|
||||||
|
If nothing is found, the role falls back to the template embedded in the role : `templates/haproxy.default.cfg.j2`
|
||||||
|
|
|
@ -18,11 +18,8 @@
|
||||||
dest: /etc/haproxy/haproxy.cfg
|
dest: /etc/haproxy/haproxy.cfg
|
||||||
force: yes
|
force: yes
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- "templates/haproxy/haproxy.{{ inventory_hostname }}.cfg.j2"
|
||||||
- "{{ inventory_hostname }}"
|
- "templates/haproxy/haproxy.{{ host_group }}.cfg.j2"
|
||||||
- "{{ host_group }}"
|
- "templates/haproxy/haproxy.default.cfg.j2"
|
||||||
- "default"
|
- "haproxy.default.cfg.j2"
|
||||||
paths:
|
|
||||||
- templates/haproxy-config
|
|
||||||
- default
|
|
||||||
notify: reload haproxy
|
notify: reload haproxy
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
global
|
global
|
||||||
log /dev/log local0
|
log /dev/log local0
|
||||||
log /dev/log local1 notice
|
log /dev/log local1 notice
|
Loading…
Reference in a new issue