ansible-collections / ansible-consul

:satellite: Ansible role for Hashicorp Consul clusters

Home Page:https://galaxy.ansible.com/ansible-community/consul/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail to start consul on debian

wilfriedroset opened this issue · comments

I've been working on deploying consul with the latest version of this role on debian 10 using the deb provided by hashicorpt (to date it's ea4686a with consul 1.11.1).
The configuration is correctly deployed but consul cannot start due to a missing file.

Dec 29 14:11:34 consul-1 systemd[1]: consul.service: Failed to load environment files: No such file or directory
Dec 29 14:11:34 consul-1 systemd[1]: consul.service: Failed to run 'start' task: No such file or directory
Dec 29 14:11:34 consul-1 systemd[1]: consul.service: Failed with result 'resources'.

This file is deployed by the package

root@90490aa3f401:/# dpkg-query -L consul
/.
/etc
/etc/consul.d
/etc/consul.d/consul.env <-- deployed here
/etc/consul.d/consul.hcl
/usr
/usr/bin
/usr/bin/consul
/usr/lib
/usr/lib/systemd
/usr/lib/systemd/system
/usr/lib/systemd/system/consul.service
/usr/share
/usr/share/doc
/usr/share/doc/consul
/usr/share/doc/consul/changelog.gz
root@90490aa3f401:/# cat /usr/lib/systemd/system/consul.service
[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/consul.d/consul.hcl

[Service]
EnvironmentFile=/etc/consul.d/consul.env <-- used here
User=consul
Group=consul
ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d/
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

The role will delete the file if present

TASK [ansible-consul : Delete non declared services] ******************************************************************
Mercredi 29 décembre 2021  15:10:25 +0100 (0:00:00.220)       0:01:19.358 *****
skipping: [consul-1] => (item=/etc/consul.d/service_node-exporter.json)
skipping: [consul-2] => (item=/etc/consul.d/service_node-exporter.json)
skipping: [consul-3] => (item=/etc/consul.d/service_node-exporter.json)
changed: [consul-1] => (item=/etc/consul.d/consul.env)
skipping: [consul-1] => (item=/etc/consul.d/service_promtail.json)
changed: [consul-2] => (item=/etc/consul.d/consul.env)
skipping: [consul-2] => (item=/etc/consul.d/service_promtail.json)
changed: [consul-3] => (item=/etc/consul.d/consul.env)
skipping: [consul-3] => (item=/etc/consul.d/service_promtail.json)

I reckon we should not delete this file as it is expected by systemd.

We can also witness the same pattern for centos 8

[root@fb00511ce6a2 /]# rpm -ql consul
/etc/consul.d/consul.env <-- here
/etc/consul.d/consul.hcl
/usr/bin/consul
/usr/lib/systemd/system/consul.service
[root@fb00511ce6a2 /]# cat /usr/lib/systemd/system/consul.service
[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/consul.d/consul.hcl

[Service]
EnvironmentFile=/etc/consul.d/consul.env <-- here
User=consul
Group=consul
ExecStart=/usr/bin/consul agent -config-dir=/etc/consul.d/
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGTERM
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target