Non-Systemd installs: setup properly proxy variables for Docker

This commit is contained in:
Alexander Kanevskiy 2016-10-29 01:16:42 +03:00
parent 33ebf124c4
commit 9377bc1b7b
3 changed files with 39 additions and 0 deletions

View file

@ -75,6 +75,15 @@
notify: restart docker notify: restart docker
when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS" when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
- name: Set docker proxy variables for non-systemd installs
template:
src: docker.j2
dest: /etc/default/docker
notify: restart docker
when: ansible_service_mgr in ["sysvinit","upstart"] and
ansible_os_family == "Debian" and
(http_proxy is defined or https_proxy is defined or no_proxy is defined)
- meta: flush_handlers - meta: flush_handlers
- name: ensure docker service is started and enabled - name: ensure docker service is started and enabled

View file

@ -0,0 +1,18 @@
# Deployed by Ansible
{% if (ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian") %}
DOCKER_OPTS="{% if docker_options is defined %}{{ docker_options }}{% endif %}"
{% else %}
OPTIONS="{% if docker_options is defined %}{{ docker_options }}{% endif %}"
{% endif %}
{% if (ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian") %}
{% if http_proxy %}
export HTTP_PROXY="{{ http_proxy }}"
{% endif %}
{% if https_proxy %}
export HTTPS_PROXY="{{ https_proxy }}"
{% endif %}
{% if no_proxy %}
export NO_PROXY="{{ no_proxy }}"
{% endif %}
{% endif %}

View file

@ -4,3 +4,15 @@ DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }} {% if docker_opt
{% else %} {% else %}
OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }} {% if docker_options is defined %}{{ docker_options }}{% endif %}" OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }} {% if docker_options is defined %}{{ docker_options }}{% endif %}"
{% endif %} {% endif %}
{% if (ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian") %}
{% if http_proxy %}
export HTTP_PROXY="{{ http_proxy }}"
{% endif %}
{% if https_proxy %}
export HTTPS_PROXY="{{ https_proxy }}"
{% endif %}
{% if no_proxy %}
export NO_PROXY="{{ no_proxy }}"
{% endif %}
{% endif %}