From 84462e784cdad243ebf133786dc80d6c43e08ed5 Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Fri, 25 Oct 2024 14:00:24 +0100 Subject: [PATCH 1/3] Create template --- .../templates/default/logstash_log-rotate.erb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 resources/templates/default/logstash_log-rotate.erb diff --git a/resources/templates/default/logstash_log-rotate.erb b/resources/templates/default/logstash_log-rotate.erb new file mode 100644 index 0000000..02e6903 --- /dev/null +++ b/resources/templates/default/logstash_log-rotate.erb @@ -0,0 +1,16 @@ +############################################################################### +# Generated by Chef # +############################################################################### + +/var/log/logstash/*.log { + size=20M + missingok + rotate 5 + compress + delaycompress + notifempty + copytruncate + postrotate + rm -f /var/log/logstash/*.gz > /dev/null + endscript +} From 01ff98d028f39df48eee2d999cbed01c092d001a Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Fri, 25 Oct 2024 14:00:46 +0100 Subject: [PATCH 2/3] Add config to create the file with the template --- resources/recipes/prepare_system.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 5850181..4daf05d 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -34,6 +34,14 @@ ) end +template "/etc/logrotate.d/logstash" do + source "logstash_log-rotate.erb" + owner "root" + group "root" + mode 0644 + retries 2 +end + service 'chef-client' do if node['redborder']['services']['chef-client'] action [:enable, :start] From 4cd16dcbcfecca0f9ef486078472da49863943cc Mon Sep 17 00:00:00 2001 From: JuanSheba Date: Fri, 25 Oct 2024 14:10:38 +0100 Subject: [PATCH 3/3] Fix lint --- resources/recipes/prepare_system.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 4daf05d..7fc9253 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -34,10 +34,10 @@ ) end -template "/etc/logrotate.d/logstash" do - source "logstash_log-rotate.erb" - owner "root" - group "root" +template '/etc/logrotate.d/logstash' do + source 'logstash_log-rotate.erb' + owner 'root' + group 'root' mode 0644 retries 2 end