From d824d6afc8dfcbc79b9a4994659c40d5894fb11c Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Mon, 10 Jan 2022 15:11:33 +0900 Subject: [PATCH] Add `systemd` config for `Promtail` monitoring `nomad`. --- .../files/lib/systemd/system/promtail-nomad.service | 12 ++++++++++++ cookbooks/nomad/setup.rb | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 cookbooks/nomad/files/lib/systemd/system/promtail-nomad.service diff --git a/cookbooks/nomad/files/lib/systemd/system/promtail-nomad.service b/cookbooks/nomad/files/lib/systemd/system/promtail-nomad.service new file mode 100644 index 0000000..a093d6f --- /dev/null +++ b/cookbooks/nomad/files/lib/systemd/system/promtail-nomad.service @@ -0,0 +1,12 @@ +[Unit] +Description=Grafana Promtail +Documentation=https://github.com/grafana/loki +After=network-online.target + +[Service] +User=root +Restart=always +ExecStart=/usr/local/bin/promtail --config.file=/etc/promtail/nomad.yaml + +[Install] +WantedBy=multi-user.target diff --git a/cookbooks/nomad/setup.rb b/cookbooks/nomad/setup.rb index d18026f..a2a5bcd 100644 --- a/cookbooks/nomad/setup.rb +++ b/cookbooks/nomad/setup.rb @@ -79,3 +79,15 @@ template '/etc/promtail/nomad.yaml' do notifies :restart, 'service[promtail-nomad]' end + +# Deploy the `systemd` configuration: +remote_file '/lib/systemd/system/promtail-nomad.service' do + owner 'root' + group 'root' + mode '644' +end + +# Service setting: +service 'promtail-nomad' do + action [ :enable, :restart ] +end