Browse Source

Merge pull request #230 from rsmitty/issue-229

Issue-229: Support Proxies in Docker Daemon
pull/244/head
Smaine Kahlouch 8 years ago
parent
commit
242e96d251
5 changed files with 37 additions and 0 deletions
  1. 5
      inventory/group_vars/all.yml
  2. 15
      roles/docker/handlers/main.yml
  3. 5
      roles/docker/tasks/main.yml
  4. 9
      roles/docker/tasks/systemd-proxies.yml
  5. 3
      roles/docker/templates/http-proxy.conf.j2

5
inventory/group_vars/all.yml

@ -123,3 +123,8 @@ dns_server: "{{ kube_service_addresses|ipaddr('net')|ipaddr(2)|ipaddr('address')
# server master2 10.99.0.27:443
# balance roundrobin
# apiserver_loadbalancer_domain_name: "lb-apiserver.kubernetes.local"
##Set these proxy values in order to update docker daemon to use proxies
#http_proxy: ""
#https_proxy: ""
#no_proxy: ""

15
roles/docker/handlers/main.yml

@ -0,0 +1,15 @@
---
- name: restart docker
command: /bin/true
notify:
- reload systemd
- reload docker
- name : reload systemd
shell: systemctl daemon-reload
when: ansible_service_mgr == "systemd"
- name: reload docker
service:
name: docker
state: restarted

5
roles/docker/tasks/main.yml

@ -53,6 +53,11 @@
with_items: "{{ docker_package_info.pkgs }}"
when: docker_package_info.pkgs|length > 0
- name: allow for proxies on systems using systemd
include: systemd-proxies.yml
when: ansible_service_mgr == "systemd" 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

9
roles/docker/tasks/systemd-proxies.yml

@ -0,0 +1,9 @@
---
- name: create docker service directory for systemd
file: path=/etc/systemd/system/docker.service.d state=directory
- name: drop docker environment conf to enable proxy usage
template:
src: http-proxy.conf.j2
dest: /etc/systemd/system/docker.service.d/http-proxy.conf
notify: restart docker

3
roles/docker/templates/http-proxy.conf.j2

@ -0,0 +1,3 @@
[Service]
Environment={% if http_proxy %}"HTTP_PROXY={{ http_proxy }}"{% endif %} {% if https_proxy %}"HTTPS_PROXY={{ https_proxy }}"{% endif %} {% if no_proxy %}"NO_PROXY={{ no_proxy }}"{% endif %}
Loading…
Cancel
Save