Skip to content

Commit 160f78f

Browse files
committed
Merge pull request #1 from sylphid8/master
initial upload
2 parents 8408225 + 90fc089 commit 160f78f

File tree

8 files changed

+186
-2
lines changed

8 files changed

+186
-2
lines changed

LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (c) 2013-2014 Salt Stack Formulas
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=========
2+
syslog-ng
3+
=========
4+
5+
Install and configure the syslog-ng service.
6+
7+
.. note::
8+
9+
See the full `Salt Formulas installation and usage instructions
10+
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.
11+
12+
Available states
13+
================
14+
15+
.. contents::
16+
:local:
17+
18+
``syslog_ng``
19+
-------
20+
21+
Install the ``sylog-ng`` package.
22+
23+
``syslog_ng.config``
24+
-----------
25+
26+
Install and configure the ``syslog-ng`` package.
27+
28+
note: if the first character of a string is '=' the string is treated as a literal (not ecapsulated in quotes)

pillar.example

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
syslog_ng:
2+
options:
3+
- threaded: yes
4+
- use_dns: no
5+
- use_fqdn: yes
6+
- keep_hostname: yes
7+
- chain_hostnames: no
8+
- check_hostname: no
9+
source:
10+
- s_internal:
11+
- internal: null
12+
- s_local:
13+
- unix-stream: /dev/log
14+
- file:
15+
- /proc/kmsg
16+
- program_override: kernel
17+
destination:
18+
- df_messages:
19+
- file:
20+
- /var/log/messages
21+
- df_secure:
22+
- file: /var/log/secure
23+
- df_console:
24+
- usertty: root
25+
- dp_devnull:
26+
- program: /bin/cat >/dev/null
27+
- dr_central:
28+
- syslog: my-remote.example.com
29+
filter:
30+
- f_messages:
31+
- level: =info..emerg
32+
- f_secure:
33+
- facility: =authpriv
34+
- f_emerg:
35+
- level: =emerg
36+
- facility: =uucp, news
37+
log:
38+
-
39+
- source: =s_internal
40+
- source: =s_local
41+
- destination: =dr_central
42+
-
43+
- source: =s_local
44+
- filter: =f_emerg
45+
- destination: =df_console
46+
-
47+
- source: =s_local
48+
- filter: =f_secure
49+
- destination: =df_secure
50+
- flags: =final
51+
-
52+
- source: =s_local
53+
- filter: =f_messages
54+
- destination: =df_messages

syslog_ng/config.sls

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% from "syslog_ng/map.jinja" import syslog_ng with context %}
2+
3+
include:
4+
- syslog_ng
5+
6+
syslog_ng.conf:
7+
file.managed:
8+
- name: {{ syslog_ng.syslog_ng_config }}
9+
- source: {{ syslog_ng.syslog_ng_config_src }}
10+
- template: mako
11+
- user: root
12+
- group: root
13+
- mode: 644
14+
- watch_in:
15+
- service: syslog_ng
16+

syslog_ng/files/syslog-ng.conf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
21+
@module tfjson
22+
23+
options {
24+
% for rule in syslog_config.get('options', []):
25+
${ rule_builder(rule) };
26+
% endfor
27+
};
28+
29+
% for obj in ('source', 'destination', 'filter', 'parser', 'rewrite', 'template'):
30+
% for params in syslog_config.get(obj, []):
31+
% for name, rules in params.items():
32+
${ obj } ${ name } {
33+
% for rule in rules:
34+
${ rule_builder(rule) };
35+
% endfor
36+
};
37+
38+
% endfor
39+
% endfor
40+
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

syslog_ng/init.sls

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% from "syslog_ng/map.jinja" import syslog_ng with context %}
2+
3+
syslog_ng:
4+
pkg.installed:
5+
- name: {{ syslog_ng.package }}
6+
7+
service.running:
8+
- enable: True
9+
- name: {{ syslog_ng.service }}
10+
- watch:
11+
- pkg: syslog_ng
12+

syslog_ng/map.jinja

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% set syslog_ng = salt['grains.filter_by']({
2+
'Debian': {
3+
'package': 'syslog-ng',
4+
'service': 'syslog-ng',
5+
'syslog_ng_config': '/etc/syslog-ng/syslog-ng.conf',
6+
'syslog_ng_config_src': 'salt://syslog_ng/files/syslog-ng.conf',
7+
},
8+
'RedHat': {
9+
'package': 'syslog-ng',
10+
'service': 'syslog-ng',
11+
'syslog_ng_config': '/etc/syslog-ng/syslog-ng.conf',
12+
'syslog_ng_config_src': 'salt://syslog_ng/files/syslog-ng.conf',
13+
},
14+
}, merge=salt['pillar.get']('syslog_ng:lookup')) %}

0 commit comments

Comments
 (0)