diff --git a/haproxy/README.md b/haproxy/README.md index 2ec46a9d..35aacd04 100644 --- a/haproxy/README.md +++ b/haproxy/README.md @@ -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`). 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` diff --git a/haproxy/tasks/main.yml b/haproxy/tasks/main.yml index 63b7a925..4ae13dea 100644 --- a/haproxy/tasks/main.yml +++ b/haproxy/tasks/main.yml @@ -18,11 +18,8 @@ dest: /etc/haproxy/haproxy.cfg force: yes with_first_found: - - files: - - "{{ inventory_hostname }}" - - "{{ host_group }}" - - "default" - paths: - - templates/haproxy-config - - default + - "templates/haproxy/haproxy.{{ inventory_hostname }}.cfg.j2" + - "templates/haproxy/haproxy.{{ host_group }}.cfg.j2" + - "templates/haproxy/haproxy.default.cfg.j2" + - "haproxy.default.cfg.j2" notify: reload haproxy diff --git a/haproxy/templates/default b/haproxy/templates/haproxy.default.cfg.j2 similarity index 97% rename from haproxy/templates/default rename to haproxy/templates/haproxy.default.cfg.j2 index 5e9cc279..0069d20a 100644 --- a/haproxy/templates/default +++ b/haproxy/templates/haproxy.default.cfg.j2 @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + global log /dev/log local0 log /dev/log local1 notice