Permalink
Browse files

fix(logrotate): remove duplicate log entry in config file generated f…

…rom webserver service install
  • Loading branch information...
phongsi committed Sep 27, 2017
1 parent 059c38c commit eabf207662b50edbe0e825c2175d44a835309941
Showing with 25 additions and 1 deletion.
  1. +13 −1 libraries/drivers_dsl_logrotate.rb
  2. +12 −0 spec/unit/recipes/configure_spec.rb
@@ -28,6 +28,18 @@ def configure_logrotate
path lr_path
lr_props.each { |k, v| send(k.to_sym, v) unless v.nil? }
end
remove_default_conf
end
def remove_default_conf
context.logrotate_app adapter do
enable false # option that will soon be deprecated
action :disable # new option but not working as of this version
end
end
def logrotate_directory
context.node['defaults']['global']['logrotate_directory']
end
def logrotate_name
@@ -51,7 +63,7 @@ def logrotate_keys
(context.node['deploy'][app['shortname']].try(:[], 'global').try(:keys) || []) +
(context.node['defaults'][driver_type].keys || []) +
(context.node['defaults']['global'].keys || [])
all_keys.uniq.map { |k| Regexp.last_match(1) if k =~ /^logrotate_(.+)/ }.compact - %w[name log_paths]
all_keys.uniq.map { |k| Regexp.last_match(1) if k =~ /^logrotate_(.+)/ }.compact - %w[name log_paths directory]
end
# rubocop:enable Metrics/AbcSize
@@ -81,6 +81,10 @@
.to enable_logrotate_app("#{aws_opsworks_app['shortname']}-nginx-staging")
end
it 'deletes default logrotate file for nginx' do
expect(chef_run).to disable_logrotate_app('nginx')
end
context 'when the logrotate settings are overridden by attributes at various levels of precedence' do
let(:logrotate_paths) { %w[/some/path/to/a.log] }
let(:chef_runner) do
@@ -482,6 +486,10 @@
.to enable_logrotate_app("#{aws_opsworks_app['shortname']}-apache2-staging")
end
it 'deletes default logrotate file for apache2' do
expect(chef_run).to disable_logrotate_app('apache2')
end
it 'creates proper .env.*' do
db_config =
Drivers::Db::Mysql.new(chef_run, aws_opsworks_app, rds: aws_opsworks_rds_db_instance(engine: 'mysql')).out
@@ -871,6 +879,10 @@
.to enable_logrotate_app("#{aws_opsworks_app['shortname']}-rails-production")
end
it 'deletes default logrotate file for apache2' do
expect(chef_run).to disable_logrotate_app('apache2')
end
context 'when default ports are overridden' do
before do
chef_runner.node.set['deploy'][aws_opsworks_app['shortname']]['webserver']['port'] = 8080

0 comments on commit eabf207

Please sign in to comment.