<% syslog_config = pillar.get('syslog_ng', {}) %>\ <%! def rule_builder(rule): if rule is None: return '' elif type(rule) is bool: return {True: 'yes', False: 'no'}[rule] elif type(rule) is int: return rule elif type(rule) is list: return ' '.join([rule_builder(v) for v in rule]) elif type(rule) is dict: return ' '.join([ '%s(%s)' % (k,rule_builder(v)) for k, v in rule.items()]) else: if rule[0] == '=': return rule[1:] return '"%s"' % rule %>\ @version: 3.3 @module tfjson 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