Skip to content

Commit

Permalink
Merge pull request #29 from cloud-bootstrap/proxy
Browse files Browse the repository at this point in the history
Proxy Settings for docker
  • Loading branch information
Carlos León committed Mar 20, 2018
2 parents a7040aa + c2b7b85 commit 6a20d80
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ So in order to upgrade Docker on managed systems, take the following steps:
host/group vars.
1. Run your playbook with `-e upgrade_docker=True`

### `docker_proxy`, `docker_http_proxy`, `docker_https_proxy`, `docker_no_proxy`

`docker_proxy` specifies if proxy need to be applied. Default value of `docker_proxy` is no. If you need proxy set it to yes and updated other three variables as needed.

Dependencies
------------
Expand Down
6 changes: 5 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ consul_ip: 127.0.0.1
docker_clusterstore: no
dockerpy: no
vagrant: no
docker_proxy: no
docker_http_proxy: ""
docker_https_proxy: ""
docker_no_proxy: ""
upgrade_docker: false
default_docker_config:
storage-driver: devicemapper
Expand All @@ -15,4 +19,4 @@ setup_script_url: "https://releases.rancher.com/install-docker/{{ docker_version
# DO NOT MODIFY THIS UNLESS YOU HAVE SPECIFIED A DIFFERENT "docker_version" or "setup_script_url"
# IF YOU HAVE GENERATED AN MD5 CHECKSUM FOR YOUR DESIRED SETUP SCRIPT, STORE IT IN THIS VARIABLE
# IF YOU REALLY DON'T WANT TO VERIFY CHECKSUM, SET THIS VALUE TO "false" or "no"
setup_script_md5_sum: "6be324016277879d49bd0e7f9f91e546"
setup_script_md5_sum: "6be324016277879d49bd0e7f9f91e546"
15 changes: 15 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
docker_json: '{{ docker_json | combine({"cluster-store": "consul://{{ consul_ip }}:8500"})}}'
when: docker_clusterstore

- name: create directory for proxy file
file:
path: /etc/systemd/system/docker.service.d
state: directory
when: docker_proxy

- name: create http-proxy.conf
template:
src: http-proxy.j2.conf
dest: /etc/systemd/system/docker.service.d/http-proxy.conf
notify:
- reload unit
- restart docker
when: docker_proxy

- name: ensure daemon config file is present
template:
src: daemon.j2.json
Expand Down
2 changes: 1 addition & 1 deletion templates/docker.j2.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/docker daemon -H unix:///var/run/docker.sock
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
Expand Down
2 changes: 2 additions & 0 deletions templates/http-proxy.j2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Service]
Environment="HTTP_PROXY={{ docker_http_proxy }}" "HTTPS_PROXY={{ docker_https_proxy }}" "NO_PROXY={{ docker_no_proxy }}"

0 comments on commit 6a20d80

Please sign in to comment.