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