Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit 5a2f423

Browse files
committed
Add syslog configuration
1 parent 12dcbcd commit 5a2f423

15 files changed

+315
-2
lines changed

README.asciidoc

+10
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,16 @@ $dns_infrastructure_names = [
897897
=== manage_firewall
898898
Indicate whether or not this module will configure the firewall for you
899899

900+
Default: false
901+
902+
=== syslog_enabled
903+
Direct logs to syslog rather than log files.
904+
905+
Default: undef
906+
907+
=== syslog_central_server_hostname
908+
Host name of the central log server where rsyslog logs will be forwarded to.
909+
900910
=== install_cartridges
901911
List of cartridges to be installed on the node. Options:
902912

files/rsyslog7_yum.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
erase rsyslog
2+
install rsyslog7 rsyslog7-mmopenshift
3+
transaction run

manifests/broker.pp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
include openshift_origin::firewall::apache
1919
include openshift_origin::selbooleans
2020
include openshift_origin::selbooleans::broker_console
21+
include openshift_origin::rsyslog
2122

2223
anchor { 'openshift_origin::broker_begin': } ->
2324
Class['openshift_origin::broker_console_dirs'] ->

manifests/init.pp

+10
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,14 @@
690690
# [*manage_firewall*]
691691
# Indicate whether or not this module will configure the firewall for you
692692
#
693+
# [*syslog_enabled*]
694+
# Direct logs to syslog rather than log files. Only works with OpenShift Enterprise 2.2
695+
# Default: false
696+
#
697+
# [*syslog_central_server_hostname*]
698+
# Host name of the central log server where rsyslog logs will be forwarded to.
699+
# Default: undef
700+
#
693701
# [*install_cartridges*]
694702
# List of cartridges to be installed on the node. Options:
695703
#
@@ -940,6 +948,8 @@
940948
$install_cartridges_recommended_deps = undef,
941949
$install_cartridges_optional_deps = undef,
942950
$manage_firewall = true,
951+
$syslog_enabled = false,
952+
$syslog_central_server_hostname = undef,
943953
) inherits openshift_origin::params {
944954
include openshift_origin::role
945955

manifests/node.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
include openshift_origin::firewall::node
2121
include openshift_origin::selbooleans
2222
include openshift_origin::selbooleans::node
23-
23+
include openshift_origin::rsyslog
24+
include openshift_origin::rsyslog::node
2425

2526
anchor { 'openshift_origin::node_begin': } ->
2627
Class['openshift_origin::selbooleans'] ->

manifests/rsyslog.pp

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2014 Red Hat, Inc., All rights reserved.
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+
#
15+
class openshift_origin::rsyslog {
16+
17+
if $::openshift_origin::syslog_enabled == true {
18+
file { '/tmp/rsyslog7_yum.txt':
19+
ensure => 'file',
20+
owner => 'root',
21+
group => 'root',
22+
source => 'puppet:///modules/openshift_origin/rsyslog7_yum.txt'
23+
}
24+
25+
exec {'install_rsyslog7':
26+
provider => shell,
27+
path => [ '/bin/', '/usr/bin/' ],
28+
logoutput => true,
29+
command => '/usr/bin/yum shell -y /tmp/rsyslog7_yum.txt',
30+
require => File['/tmp/rsyslog7_yum.txt'],
31+
unless => 'rpm -q rsyslog7'
32+
}
33+
34+
if $::openshift_origin::syslog_central_server_hostname != undef {
35+
file { '/etc/rsyslog.d/forward.conf':
36+
ensure => 'file',
37+
owner => 'root',
38+
group => 'root',
39+
content => template('openshift_origin/rsyslog/forward_conf.erb'),
40+
require => Exec['install_rsyslog7'],
41+
notify => Service['rsyslog']
42+
}
43+
}
44+
45+
service { 'rsyslog':
46+
ensure => running,
47+
enable => true,
48+
require => Exec['install_rsyslog7']
49+
}
50+
}else{
51+
service { 'rsyslog':
52+
ensure => stopped,
53+
enable => false,
54+
}
55+
}
56+
}
57+

manifests/rsyslog/node.pp

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2014 Red Hat, Inc., All rights reserved.
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+
#
15+
class openshift_origin::rsyslog::node {
16+
17+
if $::openshift_origin::syslog_enabled == true{
18+
file { '/etc/rsyslog.conf':
19+
ensure => 'file',
20+
owner => 'root',
21+
group => 'root',
22+
content => template('openshift_origin/rsyslog/rsyslog_node_conf.erb'),
23+
require => Exec['install_rsyslog7'],
24+
notify => Service['rsyslog']
25+
}
26+
27+
file { '/etc/rsyslog.d/openshift.conf':
28+
ensure => 'file',
29+
owner => 'root',
30+
group => 'root',
31+
content => template('openshift_origin/rsyslog/rsyslog_node_openshift_conf.erb'),
32+
require => Exec['install_rsyslog7'],
33+
notify => Service['rsyslog']
34+
}
35+
}
36+
37+
file { '/etc/sysconfig/httpd':
38+
ensure => 'file',
39+
owner => 'root',
40+
group => 'root',
41+
content => template('openshift_origin/node/httpd.erb'),
42+
notify => Service['httpd']
43+
}
44+
45+
file { '/etc/openshift/logshifter.conf':
46+
ensure => 'file',
47+
owner => 'root',
48+
group => 'root',
49+
content => template('openshift_origin/node/logshifter.conf.erb'),
50+
notify => [Service['openshift-watchman'], Service["${::openshift_origin::params::ruby_scl_prefix}mcollective"]]
51+
}
52+
}

templates/broker/broker.conf.erb

+5
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ ALLOW_MULTIPLE_HAPROXY_ON_NODE=<%= scope.lookupvar('::openshift_origin::conf_bro
167167
# Also this still will not create any DNS entry for the alias; that is an external step.
168168
ALLOW_ALIAS_IN_DOMAIN="false"
169169

170+
# Whether to send OpenShift log messages to syslog or to files.
171+
# If true, messages that normally end up in the Rails environment-specific log
172+
# (e.g. production.rb), usage.log, and user_action.log will instead go to syslog.
173+
SYSLOG_ENABLED="<%= scope.lookupvar('::openshift_origin::syslog_enabled') %>"
174+
170175
# Customize default app templates for specified framework cartridges.
171176
# Space-separated list of elements <cartridge-name>|<git url> - URLs must be available for all nodes.
172177
# URL will be cloned as the git repository for the cartridge at app creation unless the user specifies their own.

templates/console/console.conf.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,6 @@ PRODUCT_LOGO=<%= scope.lookupvar('::openshift_origin::console_product_logo') %>
146146
PRODUCT_TITLE=<%= scope.lookupvar('::openshift_origin::console_product_title') %>
147147

148148
# Direct logs to syslog rather than log files:
149-
#SYSLOG_ENABLED="true"
149+
SYSLOG_ENABLED="<%= scope.lookupvar('::openshift_origin::syslog_enabled') %>"
150150

151151
SESSION_SECRET="<%= scope.lookupvar('::openshift_origin::conf_console_session_secret') %>"

templates/node/httpd.erb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Configuration file for the httpd service.
2+
3+
#
4+
# The default processing model (MPM) is the process-based
5+
# 'prefork' model. A thread-based model, 'worker', is also
6+
# available, but does not work with some modules (such as PHP).
7+
# The service must be stopped before changing this variable.
8+
#
9+
#HTTPD=/usr/sbin/httpd.worker
10+
11+
#
12+
# To pass additional options (for instance, -D definitions) to the
13+
# httpd binary at startup, set OPTIONS here.
14+
#
15+
<% if scope.lookupvar('::openshift_origin::syslog_enabled') == true %>
16+
OPTIONS="-DOpenShiftFrontendSyslogEnabled -DOpenShiftAnnotateFrontendAccessLog"
17+
<% else %>
18+
#OPTIONS=
19+
<% end %>
20+
21+
#
22+
# By default, the httpd process is started in the C locale; to
23+
# change the locale in which the server runs, the HTTPD_LANG
24+
# variable can be set.
25+
#
26+
#HTTPD_LANG=C
27+
28+
#
29+
# By default, the httpd process will create the file
30+
# /var/run/httpd/httpd.pid in which it records its process
31+
# identification number when it starts. If an alternate location is
32+
# specified in httpd.conf (via the PidFile directive), the new
33+
# location needs to be reported in the PIDFILE.
34+
#
35+
#PIDFILE=/var/run/httpd/httpd.pid

templates/node/logshifter.conf.erb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
queuesize = 1000
2+
inputbuffersize = 4096
3+
<% if scope.lookupvar('::openshift_origin::syslog_enabled') == true %>
4+
outputtype = multi
5+
<% else %>
6+
outputtype = file
7+
<% end %>
8+
syslogbuffersize = 4096
9+
filebuffersize = 4096
10+
outputtypefromenviron = false
11+
filewriterdir = ~/app-root/logs

templates/node/node.conf.erb

+17
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ PLATFORM_LOG_LEVEL=DEBUG
3939
PLATFORM_TRACE_LOG_FILE=/var/log/openshift/node/platform-trace.log
4040
PLATFORM_TRACE_LOG_LEVEL=DEBUG
4141

42+
<% if scope.lookupvar('::openshift_origin::syslog_enabled') == true -%>
43+
# Uncomment and use the following lines if you want platform log entries to contain
44+
# parsable attributes associated with a given MCollective request. Possible values
45+
# are request_id, app_uuid, container_uuid, app_name, app_namespace, cart_name.
46+
# The entries will appear in the order specified.
47+
PLATFORM_LOG_CONTEXT_ENABLED=1
48+
PLATFORM_LOG_CONTEXT_ATTRS=request_id,container_uuid,app_uuid
49+
PLATFORM_LOG_CLASS=SyslogLogger
50+
51+
# Enable Metrics
52+
WATCHMAN_METRICS_ENABLED=true
53+
# How often should the watchman plugin gather metrics
54+
WATCHMAN_METRICS_INTERVAL=60
55+
# Metadata to include in messages
56+
METRICS_METADATA="appName:OPENSHIFT_APP_NAME,gear:OPENSHIFT_GEAR_UUID,app:OPENSHIFT_APP_UUID,ns:OPENSHIFT_NAMESPACE"
57+
<% end -%>
58+
4259
OPENSHIFT_FRONTEND_HTTP_PLUGINS=<%= scope.lookupvar('::openshift_origin::node_frontend_plugins').map{ |p| 'openshift-origin-frontend-' + p }.join(',') %>
4360

4461
CONTAINERIZATION_PLUGIN=openshift-origin-container-<%= scope.lookupvar('::openshift_origin::node_container_plugin') %>

templates/rsyslog/forward_conf.erb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$WorkDirectory /var/lib/rsyslog
2+
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
3+
$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
4+
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
5+
$ActionQueueType LinkedList # run asynchronously
6+
$ActionResumeRetryCount -1 # infinite retries if host is down
7+
*.* @@<%= scope.lookupvar('::openshift_origin::syslog_central_server_hostname') %>:514
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# rsyslog configuration file
2+
3+
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
4+
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
5+
6+
#### MODULES ####
7+
8+
#$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
9+
# $ModLoad imjournal # provides access to the systemd journal
10+
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
11+
#$ModLoad immark # provides --MARK-- message capability
12+
# OpenShift plugin module
13+
module(load="imuxsock" SysSock.Annotate="on" SysSock.ParseTrusted="on" SysSock.UsePIDFromSystem="on")
14+
module(load="mmopenshift")
15+
16+
# Provides UDP syslog reception
17+
#$ModLoad imudp
18+
#$UDPServerRun 514
19+
20+
# Provides TCP syslog reception
21+
#$ModLoad imtcp
22+
#$InputTCPServerRun 514
23+
24+
25+
#### GLOBAL DIRECTIVES ####
26+
27+
# Use default timestamp format
28+
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
29+
30+
# File syncing capability is disabled by default. This feature is usually not required,
31+
# not useful and an extreme performance hit
32+
#$ActionFileEnableSync on
33+
34+
# Include all config files in /etc/rsyslog.d/
35+
$IncludeConfig /etc/rsyslog.d/*.conf
36+
37+
38+
#### RULES ####
39+
40+
# Log all kernel messages to the console.
41+
# Logging much else clutters up the screen.
42+
#kern.* /dev/console
43+
44+
# Log anything (except mail) of level info or higher.
45+
# Don't log private authentication messages!
46+
*.info;mail.none;authpriv.none;cron.none /var/log/messages
47+
48+
# The authpriv file has restricted access.
49+
authpriv.* /var/log/secure
50+
51+
# Log all the mail messages in one place.
52+
mail.* -/var/log/maillog
53+
54+
55+
# Log cron stuff
56+
cron.* /var/log/cron
57+
58+
# Everybody gets emergency messages
59+
*.emerg :omusrmsg:*
60+
61+
# Save news errors of level crit and higher in a special file.
62+
uucp,news.crit /var/log/spooler
63+
64+
# Save boot messages also to boot.log
65+
local7.* /var/log/boot.log
66+
67+
68+
# ### begin forwarding rule ###
69+
# The statement between the begin ... end define a SINGLE forwarding
70+
# rule. They belong together, do NOT split them. If you create multiple
71+
# forwarding rules, duplicate the whole block!
72+
# Remote Logging (we use TCP for reliable delivery)
73+
#
74+
# An on-disk queue is created for this action. If the remote host is
75+
# down, messages are spooled to disk and sent when it is up again.
76+
#$WorkDirectory /var/lib/rsyslog # where to place spool files
77+
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
78+
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
79+
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
80+
#$ActionQueueType LinkedList # run asynchronously
81+
#$ActionResumeRetryCount -1 # infinite retries if host is down
82+
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
83+
#*.* @@remote-host:514
84+
# ### end of the forwarding rule ###
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# OpenShift plugin configuration
2+
template(name="OpenShift" type="list")
3+
{
4+
property(name="timestamp" dateFormat="rfc3339")
5+
constant(value=" ")
6+
property(name="hostname")
7+
constant(value=" ")
8+
property(name="syslogtag")
9+
constant(value=" app=")
10+
property(name="$!OpenShift!OPENSHIFT_APP_NAME")
11+
constant(value=" ns=")
12+
property(name="$!OpenShift!OPENSHIFT_NAMESPACE")
13+
constant(value=" appUuid=")
14+
property(name="$!OpenShift!OPENSHIFT_APP_UUID")
15+
constant(value=" gearUuid=")
16+
property(name="$!OpenShift!OPENSHIFT_GEAR_UUID")
17+
property(name="msg" spifno1stsp="on")
18+
property(name="msg" droplastlf="on")
19+
constant(value="n")
20+
}

0 commit comments

Comments
 (0)