in chef/cookbooks/cpe_metricbeat/resources/cpe_metricbeat.rb [101:127]
def setup_debian_service
metricbeat_dir = node['cpe_metricbeat']['dir']
unit = {
'Unit' => {
'Description' =>
'metricbeat sends log files to Logstash or directly to Elasticsearch.',
'Documentation' => ['https://www.elastic.co/products/beats/metricbeat'],
'Wants' => 'network-online.target',
'After' => 'network-online.target',
},
'Service' => {
'Type' => 'simple',
'ExecStart' => "#{metricbeat_dir}/metricbeat" \
" -c #{metricbeat_dir}/metricbeat.chef.yml",
'Restart' => 'always',
},
'Install' => {
'WantedBy' => 'multi-user.target',
},
}
systemd_unit 'metricbeat.service' do
content(unit)
action %i[create start]
subscribes :restart, 'cpe_remote_zip[metricbeat_zip]'
end
end