ETCD_DATA_DIR={{ .etcd.env.data_dir }}
ETCD_ADVERTISE_CLIENT_URLS={{ printf "https://%s:2379" .internal_ipv4 }}
ETCD_INITIAL_ADVERTISE_PEER_URLS={{ printf "https://%s:2380" .internal_ipv4 }}
ETCD_INITIAL_CLUSTER_STATE={{ .etcd.state }}
ETCD_LISTEN_CLIENT_URLS={{ printf "https://%s:2379" .internal_ipv4 }},https://127.0.0.1:2379
ETCD_INITIAL_CLUSTER_TOKEN={{ .etcd.env.token }}
ETCD_LISTEN_PEER_URLS={{ printf "https://%s:2380" .internal_ipv4 }}
ETCD_NAME={{ .hostname }}
ETCD_PROXY=off
ETCD_ENABLE_V2=true
{{- $ips := list }}
{{- range .groups.etcd | default list }}
    {{- $ips = append $ips (printf "%s=https://%s:2380" (index $.inventory_hosts . "hostname") (index $.inventory_hosts . "internal_ipv4")) }}
{{- end }}
ETCD_INITIAL_CLUSTER={{ $ips | join "," }}
ETCD_ELECTION_TIMEOUT={{ .etcd.env.election_timeout }}
ETCD_HEARTBEAT_INTERVAL={{ .etcd.env.heartbeat_interval }}
ETCD_AUTO_COMPACTION_RETENTION={{ .etcd.env.compaction_retention }}
ETCD_SNAPSHOT_COUNT={{ .etcd.env.snapshot_count }}
{{- if .etcd.metrics }}
ETCD_METRICS={{ .etcd.env.metrics }}
{{- end }}
{{- if .etcd.env.quota_backend_bytes }}
ETCD_QUOTA_BACKEND_BYTES={{ .etcd.env.quota_backend_bytes }}
{{- end }}
{{- if .etcd.env.max_request_bytes }}
ETCD_MAX_REQUEST_BYTES={{ .etcd.env.max_request_bytes }}
{{- end }}
{{- if .etcd.env.max_snapshots }}
ETCD_MAX_SNAPSHOTS={{ .etcd.env.max_snapshots }}
{{- end }}
{{- if .etcd.env.max_wals }}
ETCD_MAX_WALS={{ .etcd.env.max_wals }}
{{- end }}
{{- if .etcd.env.log_level }}
ETCD_LOG_LEVEL={{ .etcd.env.log_level }}
{{- end }}
{{- if .etcd.env.unsupported_arch }}
ETCD_UNSUPPORTED_ARCH={{ .etcd.env.unsupported_arch }}
{{- end }}

# TLS settings
ETCD_TRUSTED_CA_FILE=/etc/ssl/etcd/ssl/ca.crt
ETCD_CERT_FILE=/etc/ssl/etcd/ssl/server.crt
ETCD_KEY_FILE=/etc/ssl/etcd/ssl/server.key
ETCD_CLIENT_CERT_AUTH=true

ETCD_PEER_TRUSTED_CA_FILE=/etc/ssl/etcd/ssl/ca.crt
ETCD_PEER_CERT_FILE=/etc/ssl/etcd/ssl/server.crt
ETCD_PEER_KEY_FILE=/etc/ssl/etcd/ssl/server.key
ETCD_PEER_CLIENT_CERT_AUTH=true

# CLI settings
ETCDCTL_ENDPOINTS=https://127.0.0.1:2379
ETCDCTL_CACERT=/etc/ssl/etcd/ssl/ca.crt
ETCDCTL_CERT=/etc/ssl/etcd/ssl/server.crt
ETCDCTL_KEY=/etc/ssl/etcd/ssl/server.key
