Skip to content

Commit

Permalink
Fix the cluster advertise address templating
Browse files Browse the repository at this point in the history
  • Loading branch information
logan2211 committed Feb 4, 2019
1 parent 2b7912e commit fa1c447
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion templates/etcd.default.j2
Expand Up @@ -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 }}"
Expand Down
5 changes: 4 additions & 1 deletion vars/main.yml
Expand Up @@ -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')
)
%}
Expand Down

0 comments on commit fa1c447

Please sign in to comment.