Saltstack Official Syslog-NG Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

49 lines
1.0KB

  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: 3.3
  20. @module tfjson
  21. options {
  22. % for rule in syslog_config.get('options', []):
  23. ${ rule_builder(rule) };
  24. % endfor
  25. };
  26. % for obj in ('source', 'destination', 'filter', 'parser', 'rewrite', 'template'):
  27. % for params in syslog_config.get(obj, []):
  28. % for name, rules in params.items():
  29. ${ obj } ${ name } {
  30. % for rule in rules:
  31. ${ rule_builder(rule) };
  32. % endfor
  33. };
  34. % endfor
  35. % endfor
  36. % endfor
  37. % for loggers in syslog_config.get('log', []):
  38. log {
  39. % for rule in loggers:
  40. ${ rule_builder(rule) };
  41. % endfor
  42. };
  43. % endfor