Переглянути джерело

Merge pull request #1 from sylphid8/master

initial upload
tags/v0.2.0
Forrest 10 роки тому
джерело
коміт
160f78f9fc
8 змінених файлів з 186 додано та 2 видалено
  1. +14
    -0
      LICENSE
  2. +0
    -2
      README.md
  3. +28
    -0
      README.rst
  4. +54
    -0
      pillar.example
  5. +16
    -0
      syslog_ng/config.sls
  6. +48
    -0
      syslog_ng/files/syslog-ng.conf
  7. +12
    -0
      syslog_ng/init.sls
  8. +14
    -0
      syslog_ng/map.jinja

+ 14
- 0
LICENSE Переглянути файл

@@ -0,0 +1,14 @@
Copyright (c) 2013-2014 Salt Stack Formulas

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


+ 0
- 2
README.md Переглянути файл

@@ -1,2 +0,0 @@
syslog-ng-formula
=================

+ 28
- 0
README.rst Переглянути файл

@@ -0,0 +1,28 @@
=========
syslog-ng
=========

Install and configure the syslog-ng service.

.. note::

See the full `Salt Formulas installation and usage instructions
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.

Available states
================

.. contents::
:local:

``syslog_ng``
-------

Install the ``sylog-ng`` package.

``syslog_ng.config``
-----------

Install and configure the ``syslog-ng`` package.

note: if the first character of a string is '=' the string is treated as a literal (not ecapsulated in quotes)

+ 54
- 0
pillar.example Переглянути файл

@@ -0,0 +1,54 @@
syslog_ng:
options:
- threaded: yes
- use_dns: no
- use_fqdn: yes
- keep_hostname: yes
- chain_hostnames: no
- check_hostname: no
source:
- s_internal:
- internal: null
- s_local:
- unix-stream: /dev/log
- file:
- /proc/kmsg
- program_override: kernel
destination:
- df_messages:
- file:
- /var/log/messages
- df_secure:
- file: /var/log/secure
- df_console:
- usertty: root
- dp_devnull:
- program: /bin/cat >/dev/null
- dr_central:
- syslog: my-remote.example.com
filter:
- f_messages:
- level: =info..emerg
- f_secure:
- facility: =authpriv
- f_emerg:
- level: =emerg
- facility: =uucp, news
log:
-
- source: =s_internal
- source: =s_local
- destination: =dr_central
-
- source: =s_local
- filter: =f_emerg
- destination: =df_console
-
- source: =s_local
- filter: =f_secure
- destination: =df_secure
- flags: =final
-
- source: =s_local
- filter: =f_messages
- destination: =df_messages

+ 16
- 0
syslog_ng/config.sls Переглянути файл

@@ -0,0 +1,16 @@
{% from "syslog_ng/map.jinja" import syslog_ng with context %}

include:
- syslog_ng

syslog_ng.conf:
file.managed:
- name: {{ syslog_ng.syslog_ng_config }}
- source: {{ syslog_ng.syslog_ng_config_src }}
- template: mako
- user: root
- group: root
- mode: 644
- watch_in:
- service: syslog_ng

+ 48
- 0
syslog_ng/files/syslog-ng.conf Переглянути файл

@@ -0,0 +1,48 @@
<% 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

+ 12
- 0
syslog_ng/init.sls Переглянути файл

@@ -0,0 +1,12 @@
{% from "syslog_ng/map.jinja" import syslog_ng with context %}

syslog_ng:
pkg.installed:
- name: {{ syslog_ng.package }}

service.running:
- enable: True
- name: {{ syslog_ng.service }}
- watch:
- pkg: syslog_ng


+ 14
- 0
syslog_ng/map.jinja Переглянути файл

@@ -0,0 +1,14 @@
{% set syslog_ng = salt['grains.filter_by']({
'Debian': {
'package': 'syslog-ng',
'service': 'syslog-ng',
'syslog_ng_config': '/etc/syslog-ng/syslog-ng.conf',
'syslog_ng_config_src': 'salt://syslog_ng/files/syslog-ng.conf',
},
'RedHat': {
'package': 'syslog-ng',
'service': 'syslog-ng',
'syslog_ng_config': '/etc/syslog-ng/syslog-ng.conf',
'syslog_ng_config_src': 'salt://syslog_ng/files/syslog-ng.conf',
},
}, merge=salt['pillar.get']('syslog_ng:lookup')) %}

Завантаження…
Відмінити
Зберегти