diff --git a/README.md b/README.md index 56dac0a2..b5da0ed7 100644 --- a/README.md +++ b/README.md @@ -560,6 +560,16 @@ None - backup ``` +## Overriding configuration template + +If you can't customize via variables because an option isn't exposed, you can override the template used to generate the haproxy configuration file. + +```yaml +haproxy_conf_template: "etc/haproxy/haproxy.cfg.j2" +``` + +You can either copy and modify the provided template, or extend it with [Jinja2 template inheritance](http://jinja.pocoo.org/docs/2.9/templates/#template-inheritance) and override the specific template block you need to change. + #### License MIT diff --git a/defaults/main.yml b/defaults/main.yml index e9633944..d7e598ed 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,8 @@ haproxy_dependencies: state: latest haproxy_install: [] +haproxy_conf_template: "etc/haproxy/haproxy.cfg.j2" + # global section haproxy_global_log: - address: /dev/log diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 6670353a..b1fb1f01 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -2,7 +2,7 @@ --- - name: configuration | update file template: - src: etc/haproxy/haproxy.cfg.j2 + src: "{{ haproxy_conf_template }}" dest: /etc/haproxy/haproxy.cfg owner: root group: root