Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #412 from ttab/master
Browse files Browse the repository at this point in the history
Added support for curator 3.x
  • Loading branch information
paulczar committed Aug 22, 2015
2 parents fceb38d + 53a8431 commit 855e0a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions attributes/default.rb
Expand Up @@ -93,6 +93,8 @@
default['logstash']['instance_default']['curator_cron_hour'] = '*'
default['logstash']['instance_default']['curator_cron_log_file'] = '/dev/null'
default['logstash']['instance_default']['curator_index_prefix'] = 'logstash-'
default['logstash']['instance_default']['curator_time_unit'] = 'days'
default['logstash']['instance_default']['curator_timestring'] = '\%Y.\%m.\%d'

# Make sure instance key exists
default['logstash']['instance']
8 changes: 6 additions & 2 deletions providers/curator.rb
Expand Up @@ -19,6 +19,8 @@ def load_current_resource
@user = new_resource.user || Logstash.get_attribute_or_default(node, @instance, 'user')
@bin_dir = new_resource.bin_dir || Logstash.get_attribute_or_default(node, @instance, 'curator_bin_dir')
@index_prefix = new_resource.index_prefix || Logstash.get_attribute_or_default(node, @instance, 'curator_index_prefix')
@time_unit = new_resource.time_unit || Logstash.get_attribute_or_default(node, @instance, 'curator_time_unit')
@timestring = new_resource.timestring || Logstash.get_attribute_or_default(node, @instance, 'curator_timestring')
end

action :create do
Expand All @@ -30,6 +32,8 @@ def load_current_resource
cur_user = @user
cur_bin_dir = @bin_dir
cur_index_prefix = @index_prefix
cur_time_unit = @time_unit
cur_timestring = @timestring

@run_context.include_recipe 'python::pip'

Expand All @@ -40,7 +44,7 @@ def load_current_resource

server_ip = ::Logstash.service_ip(node, cur_instance, 'elasticsearch')
cr = cron "curator-#{cur_instance}" do
command "#{cur_bin_dir}/curator --host #{server_ip} delete --older-than #{cur_days_to_keep} --prefix #{cur_index_prefix} &> #{cur_log_file}"
command "#{cur_bin_dir}/curator --host #{server_ip} delete indices --older-than #{cur_days_to_keep} --time-unit #{cur_time_unit} --timestring '#{cur_timestring}' --prefix #{cur_index_prefix} &> #{cur_log_file}"
user cur_user
minute cur_minute
hour cur_hour
Expand All @@ -67,7 +71,7 @@ def load_current_resource
new_resource.updated_by_last_action(pi.updated_by_last_action?)

cr = cron "curator-#{cur_instance}" do
command "#{cur_bin_dir}/curator --host #{::Logstash.service_ip(node, cur_instance, 'elasticsearch')} delete --older-than #{cur_days_to_keep} --prefix #{cur_index_prefix} 2>&1 > #{cur_log_file}"
command "#{cur_bin_dir}/curator --host #{::Logstash.service_ip(node, cur_instance, 'elasticsearch')} delete indices --older-than #{cur_days_to_keep} --time-unit #{cur_time_unit} --timestring '#{cur_timestring}' --prefix #{cur_index_prefix} 2>&1 > #{cur_log_file}"
user cur_user
minute cur_minute
hour cur_hour
Expand Down
4 changes: 3 additions & 1 deletion resources/curator.rb
Expand Up @@ -16,4 +16,6 @@
attribute :log_file, kind_of: String
attribute :user, kind_of: String
attribute :bin_dir, kind_of: String
attribute :index_prefix, kind_of: String
attribute :index_prefix, kind_of: String
attribute :time_unit, kind_of: String
attribute :timestring, kind_of: String

0 comments on commit 855e0a8

Please sign in to comment.