From 20d67c13a17377ef59df9fcd0970354d90aec772 Mon Sep 17 00:00:00 2001 From: Hatifnatt Date: Thu, 26 Nov 2020 15:11:24 +0300 Subject: [PATCH] feat(config): add support for switch type parameters In config file render only key name if key value is boolean and it is 'true' --- keepalived/macro.jinja | 7 ++++++- pillar.example | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/keepalived/macro.jinja b/keepalived/macro.jinja index b5b283b..929ccbd 100644 --- a/keepalived/macro.jinja +++ b/keepalived/macro.jinja @@ -30,7 +30,12 @@ {%- if item[value] is string or item[value] is not iterable -%} {%- set forwardIndent = 0 -%} {%- endif -%} - {{- item[key]|indent(carryIndent, True) }} {{ print_config(item[value], recurse=recurse, indent=forwardIndent) -}} + {%- if item[value] is sameas true %} + {#- If curent parameter is boolen type like nopreempt, dont_track_primary, etc. just print its name -#} + {{- item[key]|indent(carryIndent, True) }}{{ '\n' -}} + {%- else %} + {{- item[key]|indent(carryIndent, True) }} {{ print_config(item[value], recurse=recurse, indent=forwardIndent) -}} + {%- endif %} {%- endif -%} {%- endfor -%} {%- else -%} diff --git a/pillar.example b/pillar.example index ee2f892..10507c1 100644 --- a/pillar.example +++ b/pillar.example @@ -39,6 +39,10 @@ keepalived: virtual_router_id: 51 priority: 100 advert_int: 1 + # switch type parameters must be defined as boolean: true / false + # 1 / 0 values will be treated as numbers + # nopreempt: true + # dont_track_primary: true authentication: auth_type: PASS auth_pass: 1111