Skip to content
Snippets Groups Projects
valkey.conf.j2 2.74 KiB
Newer Older
Chris Croome's avatar
wip
Chris Croome committed
{# j2lint: disable=jinja-variable-format #}
# {{ ansible_managed }}
#
{% if valkey_instance.name is defined %}
# Valkey configuration for {{ valkey_instance.name }}
Chris Croome's avatar
wip
Chris Croome committed
{% else %}
# Valkey configuration
Chris Croome's avatar
wip
Chris Croome committed
{% endif %}

{# Config loop, turn the dictionary into a key, value list #}
{% for valkey_var_pair in valkey_instance.config | ansible.builtin.dict2items %}
{# Description from the argument specification #}
{%     if valkey_argument_spec_options[valkey_var_pair.key].description is defined %}
Chris Croome's avatar
Chris Croome committed
{{ valkey_argument_spec_options[valkey_var_pair.key].description | wordwrap(78) | ansible.builtin.comment(prefix_count=0,postfix_count=0) }}
{%     else %}
# The {{ valkey_var_pair.key }} variable appears to be missing from the meta/argument_specs.yml
# if it was present the variable description would be printed here.
{%     endif %}
{#     If the value is a list repeat the key for each list item #}
Chris Croome's avatar
Chris Croome committed
{%     if valkey_var_pair.value | ansible.builtin.type_debug == "list" %}
{%         for valkey_var_pair_value in valkey_var_pair.value %}
{#             If the value is a boolean use yes or no as values #}
{%             if valkey_var_pair.value | ansible.builtin.type_debug == "bool" %}
{%                 if valkey_var_pair.value | bool %}
{# replace underscores with dashes in the key name #}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} yes
{%                 else %}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} no
{%                 endif %}
Chris Croome's avatar
Chris Croome committed
{#             If the value is not a interger and is an empty string print a pair of double quotes #}
{%             elif valkey_var_pair.value | ansible.builtin.type_debug != "int" and valkey_var_pair.value | length == 0 %}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} ""
{%             else %}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} {{ valkey_var_pair_value }}
{%             endif %}
{%         endfor %}
{%     else %}
{#         If the value is a boolean use yes or no as values #}
{%         if valkey_var_pair.value | ansible.builtin.type_debug == "bool" %}
{%             if valkey_var_pair.value | bool %}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} yes
{%             else %}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} no
{%             endif %}
{#         If the value in an empty string print a pair of double quotes #}
Chris Croome's avatar
Chris Croome committed
{%         elif valkey_var_pair.value | ansible.builtin.type_debug != "int" and valkey_var_pair.value | length == 0 %}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} ""
{%         else %}
{{ valkey_var_pair.key | ansible.builtin.regex_replace('_', '-') }} {{ valkey_var_pair.value }}
{%         endif %}
{%     endif %}

{% endfor %}
{# vim: syntax=jinja2 #}