Skip to content

Commit 6a3e9e8

Browse files
authored
Updating rsyslog conf (#2343)
* Updating-rsyslog-conf * Adding-daemon-reload-rsyslog * Template-update-rsyslog * Changing-rsyslog-name-restart * Updating-restart-method-rsyslog * Debugging-rsyslog-service * Enabling-rsyslog-service * Testing-sysvinit * Reworking-rsyslog-for-containers * Switching-command-to-shell-container-rsyslog * Reworking-postfix-start-stop-tasks-for-containers * Updating-conditions-rsyslog-postfix
1 parent 142c0c0 commit 6a3e9e8

File tree

4 files changed

+87
-100
lines changed

4 files changed

+87
-100
lines changed

roles/_meta/common_base/meta/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies:
3737
when: is_local is not defined or not is_local
3838
- role: debian/rkhunter
3939
when: is_local is not defined or not is_local
40+
- role: debian/rsyslog
4041
- role: debian/postfix
4142
- role: debian/clamav
4243
when: is_local is not defined or not is_local

roles/debian/postfix/tasks/main.yml

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,54 @@
143143
- postfix.disable_syslog is defined
144144
- postfix.disable_syslog
145145

146-
#- name: Restart service.
147-
# ansible.builtin.service:
148-
# name: rsyslog
149-
# state: restarted
146+
- name: Restart rsyslog based on environment to apply postfix changes
147+
block:
148+
- name: Restart rsyslog in a container to apply postfix changes (if is_local is true)
149+
ansible.builtin.shell: |
150+
pkill -HUP rsyslogd || true
151+
when: is_local
152+
153+
- name: Restart rsyslog using systemd to apply postfix changes (if is_local is false)
154+
ansible.builtin.systemd:
155+
name: rsyslog.service
156+
state: restarted
157+
when: is_local is not defined or not is_local
150158

151159
# Needed for Docker.
152-
- name: Stop Postfix
153-
ansible.builtin.command:
154-
cmd: /usr/sbin/service postfix stop
155-
156-
- name: Remove trailing lock files.
157-
ansible.builtin.file:
158-
path: "{{ lock_file }}"
159-
state: absent
160-
with_items:
161-
- /var/spool/postfix/pid/master.pid
162-
- /var/lib/postfix/master.lock
163-
loop_control:
164-
loop_var: lock_file
165-
166-
- name: Create Postfix Aliases database
167-
ansible.builtin.command:
168-
cmd: /usr/bin/newaliases
169-
170-
- name: Restart Postfix
171-
ansible.builtin.command:
172-
cmd: /usr/sbin/service postfix start
160+
- name: Manage Postfix Service
161+
block:
162+
- name: Stop Postfix in a container (if is_local is true)
163+
ansible.builtin.command:
164+
cmd: /usr/sbin/service postfix stop
165+
when: is_local
166+
167+
- name: Stop Postfix using systemd (if is_local is false)
168+
ansible.builtin.systemd:
169+
name: postfix
170+
state: stopped
171+
when: is_local is not defined or not is_local
172+
173+
- name: Remove trailing lock files
174+
ansible.builtin.file:
175+
path: "{{ lock_file }}"
176+
state: absent
177+
with_items:
178+
- /var/spool/postfix/pid/master.pid
179+
- /var/lib/postfix/master.lock
180+
loop_control:
181+
loop_var: lock_file
182+
183+
- name: Create Postfix Aliases database
184+
ansible.builtin.command:
185+
cmd: /usr/bin/newaliases
186+
187+
- name: Start Postfix in a container (if is_local is true)
188+
ansible.builtin.command:
189+
cmd: /usr/sbin/service postfix start
190+
when: is_local
191+
192+
- name: Start Postfix using systemd (if is_local is false)
193+
ansible.builtin.systemd:
194+
name: postfix
195+
state: started
196+
when: is_local is not defined or not is_local
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---
2+
- name: Install rsyslog with apt
3+
ansible.builtin.apt:
4+
name: rsyslog
5+
state: present
6+
update_cache: true
7+
28
- name: Copy rsyslog configuration in place.
39
ansible.builtin.template:
410
src: "rsyslog.{{ rsyslog.role }}.conf.j2"
@@ -8,7 +14,15 @@
814
mode: "0644"
915
force: true
1016

11-
- name: Restart service.
12-
ansible.builtin.service:
13-
name: rsyslog
14-
state: restarted
17+
- name: Restart rsyslog based on environment
18+
block:
19+
- name: Restart rsyslog in a container (if is_local is true)
20+
ansible.builtin.shell: |
21+
pkill -HUP rsyslogd || true
22+
when: is_local
23+
24+
- name: Restart rsyslog using systemd (if is_local is false)
25+
ansible.builtin.systemd:
26+
name: rsyslog.service
27+
state: restarted
28+
when: is_local is not defined or not is_local
Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
1-
# /etc/rsyslog.conf Configuration file for rsyslog.
1+
# /etc/rsyslog.conf configuration file for rsyslog
22
#
3-
# For more information see
4-
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
3+
# For more information install rsyslog-doc and see
4+
# /usr/share/doc/rsyslog-doc/html/configuration/index.html
55

66

77
#################
88
#### MODULES ####
99
#################
1010

11-
$ModLoad imuxsock # provides support for local system logging
12-
#$ModLoad imklog # provides kernel logging support
13-
#$ModLoad immark # provides --MARK-- message capability
11+
module(load="imuxsock") # provides support for local system logging
12+
module(load="imklog") # provides kernel logging support
13+
#module(load="immark") # provides --MARK-- message capability
1414

1515
# provides UDP syslog reception
16-
#$ModLoad imudp
17-
#$UDPServerRun 514
16+
#module(load="imudp")
17+
#input(type="imudp" port="514")
1818

1919
# provides TCP syslog reception
20-
#$ModLoad imtcp
21-
#$InputTCPServerRun 514
20+
#module(load="imtcp")
21+
#input(type="imtcp" port="514")
2222

2323

2424
###########################
2525
#### GLOBAL DIRECTIVES ####
2626
###########################
2727

28-
#
29-
# Use traditional timestamp format.
30-
# To enable high precision timestamps, comment out the following line.
31-
#
32-
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
33-
3428
#
3529
# Set the default permissions for all log files.
3630
#
@@ -54,68 +48,22 @@ $IncludeConfig /etc/rsyslog.d/*.conf
5448
###############
5549
#### RULES ####
5650
###############
57-
*.* @{{ rsyslog.server }}:{{ rsyslog.listen_port }}
58-
#
59-
# First some standard log files. Log by facility.
60-
#
61-
auth,authpriv.* /var/log/auth.log
62-
*.*;auth,authpriv.none -/var/log/syslog
63-
#cron.* /var/log/cron.log
64-
daemon.* -/var/log/daemon.log
65-
kern.* -/var/log/kern.log
66-
lpr.* -/var/log/lpr.log
67-
mail.* -/var/log/mail.log
68-
user.* -/var/log/user.log
69-
70-
#
71-
# Logging for the mail system. Split it up so that
72-
# it is easy to write scripts to parse these files.
73-
#
74-
mail.info -/var/log/mail.info
75-
mail.warn -/var/log/mail.warn
76-
mail.err /var/log/mail.err
7751

7852
#
79-
# Logging for INN news system.
53+
# Log anything besides private authentication messages to a single log file
8054
#
81-
news.crit /var/log/news/news.crit
82-
news.err /var/log/news/news.err
83-
news.notice -/var/log/news/news.notice
55+
*.*;auth,authpriv.none -/var/log/syslog
8456

8557
#
86-
# Some "catch-all" log files.
58+
# Log commonly used facilities to their own log file
8759
#
88-
*.=debug;\
89-
auth,authpriv.none;\
90-
news.none;mail.none -/var/log/debug
91-
*.=info;*.=notice;*.=warn;\
92-
auth,authpriv.none;\
93-
cron,daemon.none;\
94-
mail,news.none -/var/log/messages
60+
auth,authpriv.* /var/log/auth.log
61+
cron.* -/var/log/cron.log
62+
kern.* -/var/log/kern.log
63+
mail.* -/var/log/mail.log
64+
user.* -/var/log/user.log
9565

9666
#
9767
# Emergencies are sent to everybody logged in.
9868
#
99-
*.emerg :omusrmsg:*
100-
101-
#
102-
# I like to have messages displayed on the console, but only on a virtual
103-
# console I usually leave idle.
104-
#
105-
#daemon,mail.*;\
106-
# news.=crit;news.=err;news.=notice;\
107-
# *.=debug;*.=info;\
108-
# *.=notice;*.=warn /dev/tty8
109-
110-
# The named pipe /dev/xconsole is for the `xconsole' utility. To use it,
111-
# you must invoke `xconsole' with the `-file' option:
112-
#
113-
# $ xconsole -file /dev/xconsole [...]
114-
#
115-
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
116-
# busy site..
117-
#
118-
daemon.*;mail.*;\
119-
news.err;\
120-
*.=debug;*.=info;\
121-
*.=notice;*.=warn |/dev/xconsole
69+
*.emerg :omusrmsg:*

0 commit comments

Comments
 (0)