PROV_PATH={{taskserv.prov_path}}
USE_LOCALHOST={{taskserv.use_localhost}}

{% if taskserv.domain_name == "$defaults" or taskserv.domain_name == "" -%}
DOMAIN_NAME={{server.main_domain}}
{%- elif taskserv.domain_name == "$server" -%}
{%- if server.main_domain == "$default" -%}
DOMAIN_NAME={{server.main_domain}}
{%- else %}
DOMAIN_NAME={{server.main_domain}}
{%- endif %}
{%- else %}
DOMAIN_NAME={{taskserv.domain_name}}
{%- endif %}

DISCOVERY_SRV={{taskserv.discovery_srv}}
USE_DNS={{taskserv.use_dns}}
ETCD_VERSION="v{{taskserv.version}}"
{% if taskserv.name == "$hostname" %}
ETCD_NAME="{{server.hostname}}"
{%- else %}
ETCD_NAME="{{taskserv.name}}"
{%- endif %}
ETCD_CN="{{taskserv.cn}}"
ETCD_C="{{taskserv.c}}"
ETCD_PROTOCOL="{{taskserv.etcd_protocol}}"
ETCD_PORT="{{taskserv.peer_port}}"
SSL_MODE="{{taskserv.ssl_mode}}"
SIGNATURE="{{taskserv.ssl_sign}}"
CA_SIGNATURE="{{taskserv.ca_sign}}"
SSL_CURVE="{{taskserv.ssl_curve}}"
SIGN_LONG="{{taskserv.long_sign}}"
SIGN_CIPHER="{{taskserv.cipher}}"
SIGN_DAYS="{{taskserv.sign_days}}"
CA_SIGN_DAYS="{{taskserv.ca_sign_days}}"
SIGN_SHA="{{taskserv.sign_sha}}"
SOURCE_URL="{{taskserv.source_url}}"
{% if taskserv.peer_ip == "$network_private_ip" %}
ETCD_LISTEN_PEER_URLS="{{taskserv.etcd_protocol}}://{{server.network_private_ip}}:{{taskserv.peer_port}}"
ETCD_INITIAL_ADVERTISE_PEER_URLS="{{taskserv.etcd_protocol}}://{{server.network_private_ip}}:{{taskserv.peer_port}}"
{% elif taskserv.peer_ip == "$network_public_ip" and server.ip_addresses.pub -%} 
ETCD_LISTEN_PEER_URLS="{{taskserv.etcd_protocol}}://{{server.ip_addresses.pub}}:{{taskserv.peer_port}}"
ETCD_INITIAL_ADVERTISE_PEER_URLS="{{taskserv.etcd_protocol}}://{{server.ip_addresses.pub}}:{{taskserv.peer_port}}"
{%- else %}
ETCD_LISTEN_PEER_URLS="{{taskserv.etcd_protocol}}://{{taskserv.peer_ip}}:{{taskserv.peer_port}}"
ETCD_INITIAL_ADVERTISE_PEER_URLS="{{taskserv.etcd_protocol}}://{{taskserv.peer_ip}}:{{taskserv.peer_port}}"
{%- endif %}
{% if taskserv.cli_ip == "$network_private_ip" %}
ETCD_LISTEN_CLIENT_URLS="{{taskserv.etcd_protocol}}://{{server.network_private_ip}}:{{taskserv.cli_port}}"
ETCD_ADVERTISE_CLIENT_URLS="{{taskserv.etcd_protocol}}://{{server.network_private_ip}}:{{taskserv.cli_port}}"
{% elif taskserv.cli_ip == "$network_public_ip"  and server.ip_addresses.pub -%} 
ETCD_LISTEN_CLIENT_URLS="{{taskserv.etcd_protocol}}://{{server.ip_addresses.pub}}:{{taskserv.cli_port}}"
ETCD_ADVERTISE_CLIENT_URLS="{{taskserv.etcd_protocol}}://{{server.ip_addresses.pub}}:{{taskserv.cli_port}}"
{%- else %}
ETCD_LISTEN_CLIENT_URLS="{{taskserv.etcd_protocol}}://{{taskserv.cli_ip}}:{{taskserv.cli_port}}"
ETCD_ADVERTISE_CLIENT_URLS="{{taskserv.etcd_protocol}}://{{taskserv.cli_ip}}:{{taskserv.cli_port}}"
{%- endif %}
ETCD_INITIAL_CLUSTER_TOKEN="{{taskserv.token}}"
ETCD_INITIAL_CLUSTER="{{taskserv.cluster_list}}"
ETCD_TRUSTED_CA_FILE="{{taskserv.certs_path}}/ca.crt"
ETCD_CERT_FILE="{{taskserv.certs_path}}/{{taskserv.cluster_name}}.crt"
ETCD_KEY_FILE="{{taskserv.certs_path}}/{{taskserv.cluster_name}}.key"
ETCD_PEER_CLIENT_CERT_AUTH=true
ETCD_PEER_TRUSTED_CA_FILE="{{taskserv.certs_path}}/ca.crt"
ETCD_PEER_KEY_FILE="{{taskserv.certs_path}}/{{taskserv.name}}.key"
ETCD_PEER_CERT_FILE="{{taskserv.certs_path}}/{{taskserv.name}}.crt"
ETCD_DATA="{{taskserv.data_dir}}"
ETCD_CLUSTER_LIST="{{taskserv.cluster_list}}"
{% if taskserv.use_localhost and taskserv.use_localhost == "true" %}
USE_LOCALHOST="{{taskserv.use_localhost}}"
{%- endif %}
PROVISION_PATH="{{taskserv.prov_path}}"
CLUSTER_NAME="{{taskserv.cluster_name}}"
SOURCE_NAME="{{taskserv.cluster_name}}.{{taskserv.domain_name}}"

