Saltstack Official Syslog-NG Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

57 linhas
1.2KB

  1. <% syslog_config = pillar.get('syslog_ng', {}) %>\
  2. <%!
  3. def rule_builder(rule):
  4. if rule is None:
  5. return ''
  6. elif type(rule) is bool:
  7. return {True: 'yes', False: 'no'}[rule]
  8. elif type(rule) is int:
  9. return rule
  10. elif type(rule) is list:
  11. return ' '.join([rule_builder(v) for v in rule])
  12. elif type(rule) is dict:
  13. return ' '.join([ '%s(%s)' % (k,rule_builder(v)) for k, v in rule.items()])
  14. else:
  15. if rule[0] == '=':
  16. return rule[1:]
  17. return '"%s"' % rule
  18. %>\
  19. @version: ${ syslog_config.get('version', '3.3') }
  20. % for module in syslog_config.get('module', []):
  21. @module ${ rule_builder(module) }
  22. % endfor
  23. % for inc in syslog_config.get('include', []):
  24. @include ${ rule_builder(inc) }
  25. % endfor
  26. options {
  27. % for rule in syslog_config.get('options', []):
  28. ${ rule_builder(rule) };
  29. % endfor
  30. };
  31. % for obj in ('source', 'destination', 'filter', 'parser', 'rewrite', 'template'):
  32. % for params in syslog_config.get(obj, []):
  33. % for name, rules in params.items():
  34. ${ obj } ${ name } {
  35. % for rule in rules:
  36. ${ rule_builder(rule) };
  37. % endfor
  38. };
  39. % endfor
  40. % endfor
  41. % endfor
  42. % for loggers in syslog_config.get('log', []):
  43. log {
  44. % for rule in loggers:
  45. ${ rule_builder(rule) };
  46. % endfor
  47. };
  48. % endfor