From fa1c447b6a979a614fc024725b5ecad215261c4a Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 23 Nov 2018 15:11:26 -0600 Subject: [PATCH] Fix the cluster advertise address templating --- templates/etcd.default.j2 | 3 ++- vars/main.yml | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/etcd.default.j2 b/templates/etcd.default.j2 index 36a098f..e05bf79 100644 --- a/templates/etcd.default.j2 +++ b/templates/etcd.default.j2 @@ -3,7 +3,8 @@ ETCD_NAME="{{ inventory_hostname }}" {% set _initial_cluster = [] %} {% for host in groups[etcd_cluster_group] %} -{% set _ = _initial_cluster.append(host ~ '=' ~ etcd_url_scheme ~ '://' ~ hostvars[host]['etcd_advertise_address'] ~ ':' ~ etcd_peer_port) %} +{% set _host = hostvars[host]['etcd_advertise_address'] | default(hostvars[host]['ansible_host'] | default('127.0.0.1')) %} +{% set _ = _initial_cluster.append(host ~ '=' ~ etcd_url_scheme ~ '://' ~ _host ~ ':' ~ etcd_peer_port) %} {% endfor %} ETCD_INITIAL_CLUSTER="{{ _initial_cluster | join(',') }}" ETCD_DATA_DIR="{{ etcd_data_dir }}" diff --git a/vars/main.yml b/vars/main.yml index 92a6dad..fad5bc4 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -16,8 +16,11 @@ _etcd_gateway_endpoints: |- {% set _endpoints = [] %} {% for node in groups[etcd_cluster_group] | default([]) %} + {% set _host = hostvars[node]['etcd_advertise_address'] | + default(hostvars[node]['ansible_host'] | + default('127.0.0.1')) %} {% set _ = _endpoints.append( - hostvars[node]['etcd_advertise_address'] ~ ':' ~ + _host ~ ':' ~ hostvars[node]['etcd_client_port'] | default('2379') ) %}