Просмотр исходного кода

Adjust syntax for boolean values on config. Remove slack from defaults

master
Ricardo Hernandez 8 лет назад
Родитель
Сommit
43a815be08
2 измененных файлов: 12 добавлений и 18 удалений
  1. +0
    -1
      icinga2/defaults.yaml
  2. +12
    -17
      icinga2/macros.jinja

+ 0
- 1
icinga2/defaults.yaml Просмотреть файл

@@ -60,7 +60,6 @@ icinga2:
os: Linux
disk_wfree: 15%
ssh_port: 22
notification.slack: "true"
http_vhosts:
Icinga web 2:
http_uri: /icingaweb2

+ 12
- 17
icinga2/macros.jinja Просмотреть файл

@@ -1,10 +1,12 @@
{% macro printassign(key, value) %}
{%- if value is number or "vars" in value %}
{%- macro printassign(key, value) %}
{#- Check values like: 3, 25, 3s, 45m, 8d #}
{%- if value is number or "vars" in value or value in ["false","true"] or key in ["check_interval", "retry_interval"] %}
{{ key }} = {{ value }}
{#- Check string values, the more common #}
{%- elif value is string %}
{{ key }} = "{{ value }}"
{%- endif %}
{% endmacro %}
{%- endmacro %}

{%- macro printconfig(type, object, name, config, applyto="", applymethod="")%}
{%- if applymethod == "to" %}
@@ -23,30 +25,23 @@
{{key}} "{{ value }}"
{%- endif %}
{%- endfor %}
{%- for key, value in config.items() if key != "import" %}
{#- Check values like: 3, 25, 3s, 45m, 8d #}
{%- if value is number or key in ["check_interval", "retry_interval"] %}
{{ key }} = {{ value }}
{#- Check string values, the more common #}
{%- elif value is string %}
{{ key }} = "{{ value }}"
{%- for key, value in config.items() if key != "import" -%}
{{ printassign(key, value) }}
{#- Handle vars values that can be a dict, list or value #}
{%- elif key == "vars" %}
{%- if key == "vars" %}
{%- for varkey, varvalue in config.vars.items() %}
{%- if varvalue is mapping %}
{%- for k, v in varvalue.items() %}
vars.{{ varkey }}["{{ k }}"] = {
{%- if v is not none %}
{%- for k1, v1 in v.items() -%}
{{ printassign(k1, v1)|indent(4)}}
{{ printassign(k1, v1)|indent(2)}}
{%- endfor %}
{%- endif %}
}
{%- endfor %}
{%- elif varvalue is number %}
vars.{{ varkey }} = {{ varvalue }}
{%- else %}
vars.{{ varkey }} = "{{ varvalue }}"
{%- else -%}
{{ printassign("vars." + varkey, varvalue) }}
{%- endif %}
{%- endfor %}
{#- Handle dict values mapping dict type on yaml with icinga2 syntax #}
@@ -62,7 +57,7 @@
{{ key }} where {{ item }}
{%- endfor %}
{#- Handle lists values mapping list type on yaml with icinga2 syntax #}
{%- elif value is iterable %}
{%- elif value is iterable and not value is string %}
{{ key }} = [ {{ value|join(",") }} ]
{%- endif %}
{%- endfor %}

Загрузка…
Отмена
Сохранить