Merge pull request #43 from hatifnatt/support_boolean_params

feat(config): add support for switch type parameters
This commit is contained in:
Roman 2020-12-06 18:09:15 +03:00 committed by GitHub
commit 886860cb14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -30,7 +30,12 @@
{%- if item[value] is string or item[value] is not iterable -%} {%- if item[value] is string or item[value] is not iterable -%}
{%- set forwardIndent = 0 -%} {%- set forwardIndent = 0 -%}
{%- endif -%} {%- 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 -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- else -%} {%- else -%}

View File

@ -39,6 +39,10 @@ keepalived:
virtual_router_id: 51 virtual_router_id: 51
priority: 100 priority: 100
advert_int: 1 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: authentication:
auth_type: PASS auth_type: PASS
auth_pass: 1111 auth_pass: 1111