diff --git a/defaults/main.yml b/defaults/main.yml index 25ed85c..f482a10 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,7 +4,7 @@ consul_server: True consul_ui: True consul_iface: "{{ ansible_default_ipv4.interface }}" consul_bind_address: "{{ hostvars[inventory_hostname]['ansible_'+ consul_iface | replace('-', '_')]['ipv4']['address']}}" -consul_client_addr: "" +consul_client_addr: "127.0.0.1" consul_bootstrap: False consul_data_dir: "/opt/consul" @@ -24,3 +24,4 @@ consul_servers_list: "\ consul_join: [] consul_join_wan: [] +consul_bootstrap_expect: 3 diff --git a/templates/config.hcl.j2 b/templates/config.hcl.j2 index f2aa47d..f1f6019 100644 --- a/templates/config.hcl.j2 +++ b/templates/config.hcl.j2 @@ -1,7 +1,7 @@ bootstrap= {{consul_bootstrap|lower}} server= {{consul_server|lower}} - +bootstrap_expect= {{consul_bootstrap_expect}} {% if consul_bind_address %} bind_addr="{{consul_bind_address}}" {% endif %} @@ -29,7 +29,7 @@ acl { } {% for server in _consul_lan_servers %} -{% set _ = consul_join.append(hostvars[server]['consul_bind_address'] | default(hostvars[server]['ansible_default_ipv4']['address'],true) | mandatory) %} +{% set _ = consul_join.append(hostvars.server['consul_bind_address'] | default(hostvars[server]['ansible_default_ipv4']['address'],true) | mandatory) %} {% endfor %} retry_join= {{ consul_join | map('ipwrap') | list | to_json }}