From 9377bc1b7ba65a2c79eb7eb9f663112e5dc074ce Mon Sep 17 00:00:00 2001 From: Alexander Kanevskiy Date: Sat, 29 Oct 2016 01:16:42 +0300 Subject: [PATCH] Non-Systemd installs: setup properly proxy variables for Docker --- roles/docker/tasks/main.yml | 9 +++++++++ roles/docker/templates/docker.j2 | 18 ++++++++++++++++++ roles/network_plugin/flannel/templates/docker | 12 ++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 roles/docker/templates/docker.j2 diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 1d237f5e9..1ca508bd8 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -75,6 +75,15 @@ notify: restart docker 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 - name: ensure docker service is started and enabled diff --git a/roles/docker/templates/docker.j2 b/roles/docker/templates/docker.j2 new file mode 100644 index 000000000..62261748e --- /dev/null +++ b/roles/docker/templates/docker.j2 @@ -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 %} \ No newline at end of file diff --git a/roles/network_plugin/flannel/templates/docker b/roles/network_plugin/flannel/templates/docker index a0e2b052b..6522e5224 100644 --- a/roles/network_plugin/flannel/templates/docker +++ b/roles/network_plugin/flannel/templates/docker @@ -4,3 +4,15 @@ DOCKER_OPTS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }} {% if docker_opt {% else %} OPTIONS="--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }} {% 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 %} \ No newline at end of file