Xinyu Zhao 1f82f68616 Make sure only monitor the service logs per role.
If the monitored log dir does not exist, rsyslog will abort,
so make sure only monitor the logs that are existent.

Change-Id: Ic0f265a6a85d1e50d1e6e044d18ccd94f6dd5937
2014-04-22 01:51:27 +00:00

83 lines
2.3 KiB
Ruby

#
# Cookbook Name:: rsyslog
# Recipe:: client
#
# Copyright 2009-2011, Opscode, Inc.
#
# 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.
#
include_recipe "rsyslog"
roles="#{node[:roles]}"
if roles.gsub("\n",",").strip =~ /os-compute/
template "/etc/rsyslog.d/nova.conf" do
source "openstack.conf.erb"
backup false
owner "root"
group "root"
mode 0644
variables :loglist => node['rsyslog']['novalog']
notifies :restart, "service[rsyslog]"
end
end
if roles.gsub("\n",",").strip =~ /os-identity/
template "/etc/rsyslog.d/keystone.conf" do
source "openstack.conf.erb"
backup false
owner "root"
group "root"
mode 0644
variables :loglist => node['rsyslog']['keystonelog']
notifies :restart, "service[rsyslog]"
end
end
if roles.gsub("\n",",").strip =~ /os-image/
template "/etc/rsyslog.d/glance.conf" do
source "openstack.conf.erb"
backup false
owner "root"
group "root"
mode 0644
variables :loglist => node['rsyslog']['glancelog']
notifies :restart, "service[rsyslog]"
end
end
if roles.gsub("\n",",").strip =~ /os-block-storage/
template "/etc/rsyslog.d/cinder.conf" do
source "openstack.conf.erb"
backup false
owner "root"
group "root"
mode 0644
variables :loglist => node['rsyslog']['cinderlog']
notifies :restart, "service[rsyslog]"
end
end
if roles.gsub("\n",",").strip =~ /os-network/
template "/etc/rsyslog.d/quantum.conf" do
source "openstack.conf.erb"
backup false
owner "root"
group "root"
mode 0644
variables :loglist => node['rsyslog']['quantumlog']
notifies :restart, "service[rsyslog]"
end
end
file "/etc/rsyslog.d/server.conf" do
action :delete
notifies :reload, "service[rsyslog]"
only_if do ::File.exists?("/etc/rsyslog.d/server.conf") end
end