itamae/cookbooks/vector/syslog_setup.rb

63 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2020-10-31 07:53:32 +00:00
# Deploy `vector` configuration for `syslog`:
remote_file '/etc/vector/syslog.toml' do
owner 'root'
group 'root'
mode '644'
notifies :restart, 'service[vector-syslog]'
end
# Deploy `systemd` configuration for `prometheus`:
remote_file '/etc/systemd/system/vector-syslog.service' do
owner 'root'
group 'root'
mode '644'
notifies :restart, 'service[vector-syslog]'
end
# Service setting:
service 'vector-syslog' do
action [ :enable, :restart ]
end
# Firewall settings here:
%w( 514/tcp ).each do |p|
execute "ufw allow #{p}" do
user 'root'
not_if "LANG=c ufw status | grep #{p}"
notifies :run, 'execute[ufw reload-or-enable]'
end
end
execute 'ufw reload-or-enable' do
user 'root'
command 'LANG=C ufw reload | grep skipping && ufw --force enable || exit 0'
action :nothing
end
# Depoy `consul` service configuration for `loki`:
template '/etc/consul.d/service-vector-syslog.json' do
owner 'consul'
group 'consul'
2020-10-31 07:53:32 +00:00
mode '644'
variables(ipaddr: node['vector']['ipaddr'])
notifies :reload, 'service[consul]'
end
2024-04-03 07:07:27 +00:00
service 'consul' do
action :nothing
2020-10-31 07:53:32 +00:00
end
# Deploy the `logrotated` configuration:
remote_file '/etc/logrotate.d/vector-syslog' do
owner 'root'
group 'root'
mode '644'
end