hashicorp / hashicorp/consul

ca_file is not correct in generated agent-server-tls.hcl file

Open
#15,331 4 comments 0 reactions 1 assignee Claimed by @danielehc View on GitHub
type/bug type/docs
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
2d 6h
Merged PRs (30d)
43

Description

#### Overview of the Issue

I need to setup two clusters on one machine for test, so I need to change the default settings of CONSUL_CONFIG_DIR and CONSUL_DATA_DIR.

I followed the document to setup consul in linux:

https://developer.hashicorp.com/consul/tutorials/get-started-vms/virtual-machine-gs-deploy

Because I need to setup two clusters on one machine for test, so I changed the default settings from

```bash
export DATACENTER="dc1" \
export DOMAIN="consul" \
export CONSUL_DATA_DIR="/etc/consul/data" \
export CONSUL_CONFIG_DIR="/etc/consul/config" \
```

to

```bash
export DATACENTER="dc1" \
export DOMAIN="consul" \
export CONSUL_DATA_DIR="/home/sky/work/soft/consul/default/data" \
export CONSUL_CONFIG_DIR="/home/sky/work/soft/consul/default/config"
```

After I run `./generate_consul_server_config.sh and consul agent -node=consul -config-dir=${CONSUL_CONFIG_DIR}` to start consul:

```bash
==> Error loading from /etc/consul/config/consul-agent-ca.pem: open /etc/consul/config/consul-agent-ca.pem: no such file or directory
```

After I checked the generated hcl files, I found that in agent-server-tls.hcl file:

```properties
## TLS Encryption (requires cert files to be present on the server nodes)
ca_file = "/etc/consul/config/consul-agent-ca.pem"
cert_file = "/home/sky/work/soft/consul/default/config/dc1-server-consul-0.pem"
key_file = "/home/sky/work/soft/consul/default/config/dc1-server-consul-0-key.pem"
```

ca_file is not set correctly to follow CONSUL_CONFIG_DIR.

#### Reproduction Steps

https://developer.hashicorp.com/consul/tutorials/get-started-vms/virtual-machine-gs-deploy

- step1: set CONSUL_CONFIG_DIR, don't use the default value "/etc/consul/config"
- step2: run ./generate_consul_server_config.sh
- step3: run consul agent -node=consul -config-dir=${CONSUL_CONFIG_DIR}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.