Commit 6e05ccdf authored by Martin Fenner's avatar Martin Fenner Committed by Jennifer Davis
Browse files

* use correct filename for remote.conf

* renamed remote.conf in tests
* replaced depreciated tilde with stop
* optionally set hostname
* add local_host_name configuration
parent 7db9a03a
......@@ -97,7 +97,7 @@ Any previous logs are not cleaned up from the `log_dir`.
### server
Configures the node to be a rsyslog server. The chosen rsyslog server node should be defined in the `server_ip` attribute or resolvable by the specified search criteria specified in `node['rsyslog']['server_search]` (so that nodes making use of the `client` recipe can find the server to log to).
This recipe will create the logs in `node['rsyslog']['log_dir']`, and the configuration is in `/etc/rsyslog.d/server.conf`. This recipe also removes any previous configuration to a remote server by removing the `/etc/rsyslog.d/remote.conf` file.
This recipe will create the logs in `node['rsyslog']['log_dir']`, and the configuration is in `/etc/rsyslog.d/server.conf`. This recipe also removes any previous configuration to a remote server by removing the `/etc/rsyslog.d/49-remote.conf` file.
The cron job used in the previous version of this cookbook is removed, but it does not remove any existing cron job from your system (so it doesn't break anything unexpectedly). We recommend setting up logrotate for the logfiles instead.
......
......@@ -17,6 +17,7 @@
# limitations under the License.
#
default['rsyslog']['local_host_name'] = nil
default['rsyslog']['default_log_dir'] = '/var/log'
default['rsyslog']['log_dir'] = '/srv/rsyslog'
default['rsyslog']['working_dir'] = '/var/spool/rsyslog'
......
......@@ -4,7 +4,7 @@ maintainer_email 'cookbooks@chef.io'
license 'Apache 2.0'
description 'Installs and configures rsyslog'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '4.0.0'
version '4.0.4'
recipe 'rsyslog', 'Installs rsyslog'
recipe 'rsyslog::client', 'Sets up a client to log to a remote rsyslog server'
......
......@@ -39,9 +39,9 @@ template "#{node['rsyslog']['config_prefix']}/rsyslog.d/35-server-per-host.conf"
end
# if we're a server we shouldn't be sending logs to a remote like a client
file "#{node['rsyslog']['config_prefix']}/rsyslog.d/remote.conf" do
file "#{node['rsyslog']['config_prefix']}/rsyslog.d/49-remote.conf" do
action :delete
notifies :run, 'execute[validate_config]'
notifies :restart, "service[#{node['rsyslog']['service_name']}]"
only_if { ::File.exist?("#{node['rsyslog']['config_prefix']}/rsyslog.d/remote.conf") }
only_if { ::File.exist?("#{node['rsyslog']['config_prefix']}/rsyslog.d/49-remote.conf") }
end
......@@ -82,15 +82,15 @@ describe 'rsyslog::server' do
end
end
context '/etc/rsyslog.d/remote.conf file' do
context '/etc/rsyslog.d/49-remote.conf file' do
before do
allow(File).to receive(:exist?).and_return(true)
end
let(:file) { chef_run.file('/etc/rsyslog.d/remote.conf') }
let(:file) { chef_run.file('/etc/rsyslog.d/49-remote.conf') }
it 'deletes the file' do
expect(chef_run).to delete_file('/etc/rsyslog.d/remote.conf')
expect(chef_run).to delete_file('/etc/rsyslog.d/49-remote.conf')
end
it 'notifies restarting the service' do
......@@ -108,10 +108,10 @@ describe 'rsyslog::server' do
end.converge(described_recipe)
end
let(:file) { chef_run.file('/opt/local/etc/rsyslog.d/remote.conf') }
let(:file) { chef_run.file('/opt/local/etc/rsyslog.d/49-remote.conf') }
it 'deletes the file' do
expect(chef_run).to delete_file('/opt/local/etc/rsyslog.d/remote.conf')
expect(chef_run).to delete_file('/opt/local/etc/rsyslog.d/49-remote.conf')
end
it 'notifies restarting the service' do
......
......@@ -58,5 +58,5 @@ news.notice -?PerHostNewsNotice
# Stop processing of all non-local messages. You can process remote messages
# on levels less than 35.
#
:fromhost-ip,!isequal,"127.0.0.1" ~
:fromhost-ip,!isequal,"127.0.0.1" stop
<% end -%>
......@@ -7,6 +7,12 @@
#
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf
#
# Set hostname
#
<% if node['rsyslog']['local_host_name'] -%>
$LocalHostName <%= node['rsyslog']['local_host_name'] %>
<% end %>
#
# Set max message size
#
$MaxMessageSize <%= node['rsyslog']['max_message_size'] %>
......
require 'fileutils'
unless Dir.exist?("#{node['rsyslog']['config_prefix']}/rsyslog.d")
FileUtils.mkdir("#{node['rsyslog']['config_prefix']}/rsyslog.d")
unless Dir.exist?("#{node['rsyslog']['config_prefix']}/49-rsyslog.d")
FileUtils.mkdir("#{node['rsyslog']['config_prefix']}/49-rsyslog.d")
end
FileUtils.touch("#{node['rsyslog']['config_prefix']}/rsyslog.d/remote.conf")
FileUtils.touch("#{node['rsyslog']['config_prefix']}/rsyslog.d/49-remote.conf")
include_recipe 'rsyslog::server'
......@@ -8,6 +8,6 @@ describe file('/etc/rsyslog.d/35-server-per-host.conf') do
it { should be_file }
end
describe file('/etc/rsyslog.d/remote.conf') do
describe file('/etc/rsyslog.d/49-remote.conf') do
it { should_not be_file }
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment