#
# Cookbook:: irrigate-fluentd
# Recipe:: windows_events
#
# Copyright: The Orchard
#

# Configure source for windows events
template 'c:/opt/td-agent/conf/conf.d/source-windows-events.conf' do
  source 'source_windows.conf.erb'
  variables ({
    parse_type: node['fluentd']['windows-events']['type'],
    id: node['fluentd']['windows-events']['id'],
    channels: node['fluentd']['windows-events']['channels'],
    read_interval: node['fluentd']['windows-events']['read_interval'],
    tag: node['fluentd']['windows-events']['tag'],
  })
  notifies :restart, 'windows_service[fluentdwinsvc]', :delayed
end

# Configure filter for windows events
template 'c:/opt/td-agent/conf/conf.d/filter-windows-events.conf' do
  source 'filter_windows.conf.erb'
  variables ({
    name: node['fluentd']['windows-events']['tag'],
    type: node['fluentd']['windows-events']['id'],
  })
  notifies :restart, 'windows_service[fluentdwinsvc]', :delayed
end

# Fluentd service
windows_service 'fluentdwinsvc' do
  supports start: true, restart: true, stop: true, configure_startup: true
  action :nothing
  startup_type :automatic
end
