# {{ ansible_managed }}

# https://etcd.io/docs/v3.5/op-guide/configuration/

name: {{ etcd_instance }}

data-dir: {{ etcd_data }}

#enable-v2: yes

initial-cluster-token: "{{ etcd_cluster }}"

initial-cluster-state: "{{ etcd_init|default('new') }}"

initial-cluster: "{% for ip in groups[etcd_cluster]|sort %}{% if not loop.first %},{% endif %}{{ etcd_cluster }}-{{ hostvars[ip].etcd_seq }}=https://{{ ip }}:{{ etcd_peer_port }}{% endfor %}"

initial-advertise-peer-urls: "https://{{ inventory_hostname }}:{{ etcd_peer_port }}"

listen-peer-urls: "https://{{ inventory_hostname }}:{{ etcd_peer_port }}"

listen-client-urls: "https://{{ inventory_hostname }}:{{ etcd_port }},https://127.0.0.1:{{ etcd_port }}"

advertise-client-urls: "https://{{ inventory_hostname }}:{{ etcd_port }}"

election-timeout: {{ etcd_election_timeout|default(1000) }}

heartbeat-interval: {{ etcd_heartbeat_interval|default(100) }}

# increase default quota from 2 GiB to 16 GiB
quota-backend-bytes: 17179869184

# important: enable auto compaction
auto-compaction-mode: periodic

# keep history in last 24 hour
auto-compaction-retention: "24h"

client-transport-security: # use etcd certs
  cert-file: "/etc/etcd/server.crt"
  key-file:  "/etc/etcd/server.key"
  trusted-ca-file: "/etc/etcd/ca.crt"

peer-transport-security: # use as peer certs
  cert-file: "/etc/etcd/server.crt"
  key-file:  "/etc/etcd/server.key"
  trusted-ca-file: "/etc/etcd/ca.crt"

