Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint fb_syslog; delete uncontrolled files #208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cookbooks/fb_syslog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Attributes
* node['fb_syslog']['rsyslog_use_omprog_force']
* node['fb_syslog']['rsyslog_stats_logging']
* node['fb_syslog']['rsyslog_report_suspension']
* node['fb_syslog']['rsyslog_d_preserve']
* node['fb_syslog']['sysconfig']['vars'][$KEY][$VAL]
* node['fb_syslog']['sysconfig']['extra_lines']

Expand Down Expand Up @@ -244,6 +245,11 @@ Set `node['fb_syslog']['rsyslog_stats_logging']` to true to enable periodic
output of rsyslog internal counters. These will be logged using the `impstats`
module to `/var/log/rsyslog-stats.log`.

### Controlling the syslog.d directory
By default, we will delete everything in the `/etc/rsyslog.d`, as all rsyslog
configuration should be controlled by users of this API. However, if you need
to preserve such files, set `node['fb_syslog']['rsyslog_d_preserve']` to `true`.

### sysconfig settings
On non-systemd systems, `node['fb_syslog']['sysconfig']` can be used
to setup `/etc/sysconfig/rsyslog` (for RedHat machines) or
Expand Down
13 changes: 12 additions & 1 deletion cookbooks/fb_syslog/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
'debian' => '/var/log/syslog',
)

authlog = value_for_platform_family(
['rhel', 'fedora'] => '/var/log/secure',
'default' => '/var/log/auth.log',
)

# Add in some reasonable defaults for all syslog.confs
default['fb_syslog'] = {
'syslog-entries' => {
Expand All @@ -43,9 +48,14 @@
'comment' => 'Log anything info level or higher. A lot ' +
'of things go into their own file.',
'selector' => '*.info;mail,authpriv,cron,' +
'local0,local1,local2,local3,local5,local6,local7.none',
'local0,local1,local2,local3,local4,local5,local6,local7.none',
'action' => "-#{syslog_file}",
},
'authlog' => {
'comment' => 'Log all auth stuff',
'selector' => 'auth,authpriv.*',
'action' => authlog,
},
'mail' => {
'comment' => 'Log all the mail messages in one place.',
'selector' => 'mail.*',
Expand Down Expand Up @@ -88,6 +98,7 @@
'$DirCreateMode 0755',
'$Umask 0002',
],
'rsyslog_d_preserve' => false,
'rsyslog_late_lines' => [],
'rsyslog_additional_sockets' => [],
'rsyslog_facilities_sent_to_remote' => [],
Expand Down
7 changes: 7 additions & 0 deletions cookbooks/fb_syslog/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
notifies :restart, "service[#{service_name}]"
end

directory '/etc/rsyslog.d' do
not_if { node['fb_syslog']['rsyslog_d_preserve'] }
action :delete
recursive true
notifies :restart, "service[#{service_name}]"
end

service service_name do
action :start
subscribes :restart, 'package[rsyslog]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")

Expand Down
2 changes: 1 addition & 1 deletion cookbooks/fb_syslog/spec/fixtures/centos6/rsyslog.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
$OmitLocalLogging off
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/fb_syslog/spec/fixtures/centos7/rsyslog.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
$OmitLocalLogging off
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
$OmitLocalLogging off
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
$OmitLocalLogging off
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/fb_syslog/spec/fixtures/centos8/rsyslog.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
$OmitLocalLogging off
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
$OmitLocalLogging off
# Provides kernel logging support (previously done by rklogd)
module(load="imklog")
Expand Down
8 changes: 5 additions & 3 deletions cookbooks/fb_syslog/templates/default/rsyslog.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $PreserveFQDN on

#### MODULES ####
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
module(load="imuxsock")
<% if node.centos? && !node.centos6? -%>
$OmitLocalLogging off
<% end -%>
Expand All @@ -27,8 +27,10 @@ module(load="omprog")
<% end -%>
<% if node['fb_syslog']['rsyslog_server'] -%>
# UDP / TCP reception
$ModLoad imudp
$ModLoad imtcp
module(load="imtcp")
input(type="imtcp" port="514")
module(load="imudp")
input(type="imudp" port="514")

<% if node['fb_syslog']['rsyslog_server_address'] -%>
$UDPServerAddress <%= node['fb_syslog']['rsyslog_server_address'] %>
Expand Down