# {{ ansible_managed }}

# Docker Upstart and SysVinit configuration file

# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"

{% set docker_server__tpl_options = [] %}
{% if docker_server__graph|d() %}
{%   set _ = docker_server__tpl_options.append("--graph " + docker_server__graph) %}
{% endif %}
{% if docker_server__bridge|d() %}
{%   set _ = docker_server__tpl_options.append("--bridge " + docker_server__bridge) %}
{% endif %}
{% if docker_server__fixed_cidr|d() %}
{%   set _ = docker_server__tpl_options.append("--fixed-cidr " + docker_server__fixed_cidr) %}
{% endif %}
{% if docker_server__dns_nameserver|d() %}
{%   for nameserver in docker_server__dns_nameserver %}
{%     set _ = docker_server__tpl_options.append("--dns " + nameserver) %}
{%   endfor %}
{% endif %}
{% if docker_server__dns_search|d() %}
{%   for domain in docker_server__dns_search %}
{%     set _ = docker_server__tpl_options.append("--dns-search " + domain) %}
{%   endfor %}
{% endif %}
{% if docker_server__listen|d() %}
{%   for host in docker_server__listen %}
{%     if host|length %}
{%       set _ = docker_server__tpl_options.append("-H " + host) %}
{%     endif %}
{%   endfor %}
{% endif %}
{% if docker_server__pki|d() | bool %}
{%   set _ = docker_server__tpl_options.append("--tlsverify") %}
{%   set _ = docker_server__tpl_options.append("--tlscacert " + docker_server__pki_path + "/" + docker_server__pki_realm + "/" + docker_server__pki_ca) %}
{%   set _ = docker_server__tpl_options.append("--tlscert " + docker_server__pki_path + "/" + docker_server__pki_realm + "/" + docker_server__pki_crt) %}
{%   set _ = docker_server__tpl_options.append("--tlskey " + docker_server__pki_path + "/" + docker_server__pki_realm + "/" + docker_server__pki_key) %}
{% endif %}
{% if docker_server__labels|d() %}
{%   for key, value in docker_server__labels.items() %}
{%     set _ = docker_server__tpl_options.append("--label " + key + '="' + value + '"') %}
{%   endfor %}
{% endif %}
{% if docker_server__debug|d() | bool %}
{%   set _ = docker_server__tpl_options.append("--debug=true") %}
{% endif %}
{% if docker_server__registry_mirrors|d() %}
{%   for registry_mirror in docker_server__registry_mirrors %}
{%     if registry_mirror %}
{%       set _ = docker_server__tpl_options.append("--registry-mirror" + " " + registry_mirror) %}
{%     endif %}
{%   endfor %}
{% endif %}
{% if docker_server__options|d() %}
{%   for option in docker_server__options %}
{%     if option %}
{%       set _ = docker_server__tpl_options.append(option) %}
{%     endif %}
{%   endfor %}
{% endif %}
# Use DOCKER_OPTS to modify the daemon startup options.
{% if docker_server__tpl_options %}
DOCKER_OPTS='{{ docker_server__tpl_options | join(" ") }}'
{% else %}
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
{% endif %}

{% if docker_server__env_http_proxy|d() %}
export http_proxy={{ docker_server__env_http_proxy }}
{% endif %}
{% if docker_server__env_https_proxy|d() %}
export https_proxy={{ docker_server__env_https_proxy }}
{% endif %}
{% if docker_server__env_no_proxy|d() %}
export no_proxy={{ docker_server__env_no_proxy }}
{% endif %}
# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"
