From c2ff2fe9f08e6f623a8ed370c6412782bf89be9d Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Tue, 30 Jun 2020 06:28:39 +0000 Subject: [PATCH] Adjust acl option yaml input syntax Signed-off-by: Mike Beattie --- templates/etc/haproxy/backend.cfg.j2 | 10 +++++++++- templates/etc/haproxy/frontend.cfg.j2 | 10 +++++++++- templates/etc/haproxy/listen.cfg.j2 | 10 +++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index 855b2f09..137dd218 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -23,9 +23,17 @@ backend {{ backend.name }} {% if backend.cookie is defined %} cookie {{ backend.cookie }} {% endif %} +{% if backend.acl is defined %} +{% if backend.acl is mapping %} +{% for name, value in backend.acl.items() %} + acl {{ name }} {{ value }} +{% endfor %} +{% else %} {% for acl in backend.acl | default([]) %} - acl {{ acl.string }} + acl {{ acl.string | default(acl) }} {% endfor %} +{% endif %} +{% endif %} {% for stick in backend.stick | default([]) %} stick-table {{ stick.table }} stick on {{ stick.stick_on }} diff --git a/templates/etc/haproxy/frontend.cfg.j2 b/templates/etc/haproxy/frontend.cfg.j2 index 465c89f7..2313b6db 100644 --- a/templates/etc/haproxy/frontend.cfg.j2 +++ b/templates/etc/haproxy/frontend.cfg.j2 @@ -32,9 +32,17 @@ frontend {{ frontend.name }} {% for timeout in frontend.timeout | default([]) %} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} +{% if frontend.acl is defined %} +{% if frontend.acl is mapping %} +{% for name, value in frontend.acl.items() %} + acl {{ name }} {{ value }} +{% endfor %} +{% else %} {% for acl in frontend.acl | default([]) %} - acl {{ acl.string }} + acl {{ acl.string | default(acl) }} {% endfor %} +{% endif %} +{% endif %} {% for capture in frontend.capture | default([]) %} capture {{ capture.type }} {{ capture.name }} len {{ capture.length }} {% endfor %} diff --git a/templates/etc/haproxy/listen.cfg.j2 b/templates/etc/haproxy/listen.cfg.j2 index b46bfe92..dcd9dff2 100644 --- a/templates/etc/haproxy/listen.cfg.j2 +++ b/templates/etc/haproxy/listen.cfg.j2 @@ -42,9 +42,17 @@ listen {{ listen.name }} {% for timeout in listen.timeout | default([]) %} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} +{% if listen.acl is defined %} +{% if listen.acl is mapping %} +{% for name, value in listen.acl.items() %} + acl {{ name }} {{ value }} +{% endfor %} +{% else %} {% for acl in listen.acl | default([]) %} - acl {{ acl.string }} + acl {{ acl.string | default(acl) }} {% endfor %} +{% endif %} +{% endif %} {% for capture in listen.capture | default([]) %} capture {{ capture.type }} {{ capture.name }} len {{ capture.length }} {% endfor %}