|
- {%- set syslog_config = pillar.get('syslog_ng', {}) -%}
-
- {%- macro rule_builder(rule) -%}
- {%- if rule is none -%}
- {%- elif rule is sameas true -%}
- yes
- {%- elif rule is sameas false -%}
- no
- {%- elif rule is number -%}
- {{ rule }}
- {%- elif rule is mapping -%}
- {%- for k, v in rule.items() -%}
- {{ k }}({{ rule_builder(v) }})
- {%- endfor -%}
- {%- elif rule is iterable and rule is not string -%}
- {%- for v in rule -%}
- {{ rule_builder(v) }}
- {%- endfor -%}
- {%- else -%}
- {%- if rule[0] == '=' -%}
- {{ rule[1:] }}
- {%- else -%}
- "{{ rule }}"
- {%- endif -%}
- {%- endif -%}
- {%- endmacro -%}
-
- @version: {{ syslog_config.get('version', '3.3') }}
-
- {%- for module in syslog_config.get('module', []) %}
- @module {{ rule_builder(module) }}
- {%- endfor %}
-
- {%- for inc in syslog_config.get('include', []) %}
- @include {{ rule_builder(inc) }}
- {%- endfor %}
-
- options {
- {%- for rule in syslog_config.get('options', []) %}
- {{ rule_builder(rule) }};
- {%- endfor %}
- };
-
- {%- for obj in ('source', 'destination', 'filter', 'parser', 'rewrite', 'template') %}
- {%- for params in syslog_config.get(obj, []) %}
- {% for name, rules in params.items() %}
- {{ obj }} {{ name }} {
- {%- for rule in rules %}
- {{ rule_builder(rule) }};
- {%- endfor %}
- };
- {%- endfor %}
- {%- endfor %}
- {%- endfor %}
-
- {% for loggers in syslog_config.get('log', []) -%}
- log {
- {%- for rule in loggers %}
- {{ rule_builder(rule) }};
- {%- endfor %}
- };
- {%- endfor %}
|