Commit 1839f1be authored by Mihai Petracovici's avatar Mihai Petracovici
Browse files

Additional Rubocop fixes

parent fe45718f
......@@ -37,7 +37,7 @@ default['rsyslog']['repeated_msg_reduction'] = 'on'
default['rsyslog']['logs_to_forward'] = '*.*'
default['rsyslog']['enable_imklog'] = true
default['rsyslog']['config_prefix'] = '/etc'
default['rsyslog']['default_file_template'] = nil
default['rsyslog']['default_file_template'] = nil
default['rsyslog']['default_remote_template'] = nil
default['rsyslog']['rate_limit_interval'] = nil
default['rsyslog']['rate_limit_burst'] = nil
......
module RsyslogCookbook
# helpers for the various service providers on Ubuntu systems
module Helpers
def declare_rsyslog_service
if 'ubuntu' == node['platform']
if Chef::VersionConstraint.new('>= 15.04').include?(node['platform_version'])
service_provider = Chef::Provider::Service::Systemd
elsif Chef::VersionConstraint.new('>= 12.04').include?(node['platform_version'])
service_provider = Chef::Provider::Service::Upstart
else
service_provider = nil
end
def find_provider
if Chef::VersionConstraint.new('>= 15.04').include?(node['platform_version'])
service_provider = Chef::Provider::Service::Systemd
elsif Chef::VersionConstraint.new('>= 12.04').include?(node['platform_version'])
service_provider = Chef::Provider::Service::Upstart
else
service_provider = nil
end
service_provider
end
def declare_rsyslog_service
service_provider = 'ubuntu' == node['platform'] ? find_provider : nil
service 'rsyslog' do
service_name node['rsyslog']['service_name']
......
......@@ -33,7 +33,7 @@ directory "#{node['rsyslog']['config_prefix']}/rsyslog.d" do
mode '0755'
end
directory node['rsyslog']['working_dir'] do
directory node['rsyslog']['working_dir'] do
owner node['rsyslog']['user']
group node['rsyslog']['group']
mode '0700'
......
......@@ -31,9 +31,9 @@ describe 'rsyslog::client' do
let(:template) { chef_run.template('/etc/rsyslog.d/49-remote.conf') }
it 'creates the template' do
expect(chef_run).to render_file(template.path).with_content { |content|
expect(content).to include("*.* @@#{server_ip}:514")
expect(content).to include("#{custom_remote.first['logs']} @@#{custom_remote.first['server']}:#{custom_remote.first['port']};#{custom_remote.first['remote_template']}")
expect(chef_run).to render_file(template.path).with_content { |content|
expect(content).to include("*.* @@#{server_ip}:514")
expect(content).to include("#{custom_remote.first['logs']} @@#{custom_remote.first['server']}:#{custom_remote.first['port']};#{custom_remote.first['remote_template']}")
}
end
......@@ -61,10 +61,10 @@ describe 'rsyslog::client' do
let(:template) { chef_run.template('/opt/local/etc/rsyslog.d/49-remote.conf') }
it 'creates the template' do
expect(chef_run).to render_file(template.path).with_content { |content|
expect(content).to include("*.* @@#{server_ip}:514")
expect(content).to include("#{custom_remote.first['logs']} @@#{custom_remote.first['server']}:#{custom_remote.first['port']};#{custom_remote.first['remote_template']}")
}
expect(chef_run).to render_file(template.path).with_content { |content|
expect(content).to include("*.* @@#{server_ip}:514")
expect(content).to include("#{custom_remote.first['logs']} @@#{custom_remote.first['server']}:#{custom_remote.first['port']};#{custom_remote.first['remote_template']}")
}
end
it 'is owned by root:root' do
......
require 'fileutils'
unless Dir.exists?("#{node['rsyslog']['config_prefix']}/rsyslog.d")
FileUtils.mkdir("#{node['rsyslog']['config_prefix']}/rsyslog.d")
unless Dir.exist?("#{node['rsyslog']['config_prefix']}/rsyslog.d")
FileUtils.mkdir("#{node['rsyslog']['config_prefix']}/rsyslog.d")
end
FileUtils.touch("#{node['rsyslog']['config_prefix']}/rsyslog.d/server.conf")
......
Markdown is supported
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