resource_name :ossec_ruleset

property :ruleset_dir, String, required: true
property :ruleset_url, String, required: true

default_action :nothing

action :setup do
  directory ruleset_dir do
    recursive true
    not_if "test -d #{ruleset_dir}"
  end

  remote_file "#{ruleset_dir}/ossec_ruleset.py" do
    source ruleset_url
  end

  template '/etc/cron.weekly/update_ruleset.sh' do
    source 'ossec/update_ruleset.sh.erb'
    mode '0755'
    variables(
      'ruleset_script_path' => "#{ruleset_dir}/ossec_ruleset.py"
    )
  end
end

action :update do
  remote_file "#{ruleset_dir}/ossec_ruleset.py" do
    source ruleset_url
  end
end
