# contiv etcd config
{% if inventory_hostname in groups['kube-master'] %}
export ETCD_DATA_DIR=/var/lib/etcd/contiv-data
export ETCD_ADVERTISE_CLIENT_URLS={{ contiv_etcd_ad_urls }}
export ETCD_INITIAL_ADVERTISE_PEER_URLS={{ contiv_etcd_peer_urls }}
export ETCD_LISTEN_PEER_URLS={{ contiv_etcd_peer_urls }}
export ETCD_LISTEN_CLIENT_URLS={{ contiv_etcd_listen_urls | join(",") }}
export ETCD_NAME=
{%- for host in groups['kube-master'] -%}
{%- if host == inventory_hostname -%}
contiv_etcd{{ loop.index }}
{%- endif %}
{%- endfor %}

{% else %}
export ETCD_LISTEN_CLIENT_URLS=http://127.0.0.1:{{ contiv_etcd_listen_port }}
export ETCD_PROXY=on
{% endif %}
export ETCD_INITIAL_CLUSTER=
{%- for host in groups['kube-master'] -%}
contiv_etcd{{ loop.index }}=http://{{ hostvars[host]['ip'] | default(hostvars[host].ansible_default_ipv4['address']) }}:{{ contiv_etcd_peer_port }},
{%- endfor -%}
