84 lines
1.5 KiB
Ruby
84 lines
1.5 KiB
Ruby
# Create `/etc/loki/`:
|
|
%w(/etc/loki).each do |d|
|
|
directory d do
|
|
owner 'root'
|
|
group 'root'
|
|
mode '0755'
|
|
end
|
|
end
|
|
|
|
# Deploy `prometheus` files:
|
|
template '/etc/loki/loki-config.yml' do
|
|
owner 'root'
|
|
group 'root'
|
|
mode '644'
|
|
|
|
variables(ipaddr: node['consul']['ipaddr'])
|
|
|
|
notifies :restart, 'service[loki]'
|
|
end
|
|
|
|
# Deploy `systemd` configuration for `prometheus`:
|
|
remote_file '/etc/systemd/system/loki.service' do
|
|
owner 'root'
|
|
group 'root'
|
|
mode '644'
|
|
end
|
|
|
|
# Service setting:
|
|
service 'loki' do
|
|
action [ :enable, :restart ]
|
|
end
|
|
|
|
# Depoy `consul` service configuration for `loki`:
|
|
template '/etc/consul.d/service-loki.json' do
|
|
owner 'consul'
|
|
group 'consul'
|
|
mode '644'
|
|
|
|
variables(ipaddr: node['consul']['ipaddr'])
|
|
|
|
notifies :reload, 'service[consul]'
|
|
end
|
|
|
|
service 'consul' do
|
|
action :nothing
|
|
end
|
|
|
|
remote_file '/etc/rsyslog.d/30-loki.conf' do
|
|
owner 'root'
|
|
group 'root'
|
|
mode '644'
|
|
|
|
notifies :restart, 'service[rsyslog]'
|
|
end
|
|
|
|
service 'rsyslog' do
|
|
action [ :nothing ]
|
|
end
|
|
|
|
# Deploy the `logrotated` configuration:
|
|
remote_file '/etc/logrotate.d/loki' do
|
|
owner 'root'
|
|
group 'root'
|
|
mode '644'
|
|
end
|
|
|
|
# Firewall settings here:
|
|
%w( 3100/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
|