in chef/cookbooks/cpe_filebeat/resources/cpe_filebeat.rb [118:164]
def configure
if filebeat_conf.empty? || filebeat_conf.nil?
Chef::Log.warn('config is not populated, skipping configuration')
return
end
cookbook_file certificate_path do
source certificate
owner root_owner
group node['root_group']
mode '0644' unless windows?
not_if { certificate.nil? }
end
setup_macos_service if macos?
setup_debian_service if debian?
prefix = node['cpe_launchd']['prefix'] || 'com.uber.chef'
service_info = value_for_platform_family(
'mac_os_x' => { 'launchd' => "#{prefix}.filebeat" },
'debian' => { 'systemd_unit' => 'filebeat.service' },
'windows' => { 'windows_service' => 'Filebeat Service' },
'default' => nil,
)
service_type, service_name = service_info.first
if macos?
launchd service_name do
action :nothing
only_if { ::File.exist?("/Library/LaunchDaemons/#{service_name}.plist") }
subscribes :restart, 'cpe_remote_zip[filebeat_zip]'
end
end
config = ::File.join(filebeat_dir, 'filebeat.chef.yml')
file config do
owner root_owner
group node['root_group']
content YAML.dump(filebeat_conf)
notifies :restart, "#{service_type}[#{service_name}]"
end
setup_windows_service if windows?
end