Skip to content

Commit

Permalink
Merge pull request #122 from lhoss/configurable_proxy
Browse files Browse the repository at this point in the history
Configurable proxy in the docker config
  • Loading branch information
angstwad authored Dec 24, 2016
2 parents 3c8d166 + 3eee49c commit 0af1f02
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ apt_repository: deb https://apt.dockerproject.org/repo {{ ansible_lsb.id|lower }
# -H tcp://0.0.0.0:2375
# --log-level=debug
docker_opts: ""
# configurable proxies: a reasonable default is to re-use the proxy from ansible_env:
# docker_http_proxy: "{{ ansible_env.http_proxy|default('') }}"
# Notes:
# if docker_http_proxy=="" the role sets HTTP_PROXY="" (useful to 'empty' existing ENV var)
# if docker_http_proxy is undefined the role will not set/modify any ENV vars
docker_http_proxy:
docker_https_proxy:
# List of users to be added to 'docker' system group (disabled by default)
# SECURITY WARNING: 
# Be aware that granted users can easily get full root access on the docker host system!
Expand Down
9 changes: 9 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ docker_opts: ""
# SECURITY WARNING: 
# Be aware that granted users can easily get full root access on the docker host system!
docker_group_members: []

# configurable proxies: a reasonable default is to re-use the proxy from ansible_env:
# docker_http_proxy: "{{ ansible_env.http_proxy|default('') }}"
# Notes:
# if docker_http_proxy=="" the role sets HTTP_PROXY="" (useful to 'empty' existing ENV var)
# if docker_http_proxy is undefined the role will not set/modify any ENV vars
docker_http_proxy:
docker_https_proxy:

# Flags for whether to install pip packages
pip_install_pip: true
pip_install_setuptools: true
Expand Down
22 changes: 22 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@
line: "DEFAULT_FORWARD_POLICY=\"ACCEPT\""
when: ufw_default_exists.stat.exists

- name: Set docker HTTP_PROXY if docker_http_proxy defined
lineinfile:
dest: /etc/default/docker
regexp: "^export HTTP_PROXY="
line: "export HTTP_PROXY=\"{{docker_http_proxy}}\""
state: present
when: docker_http_proxy is defined and (docker_http_proxy != None)
notify:
- Restart docker
tags: proxy

- name: Set docker HTTPS_PROXY if docker_https_proxy defined
lineinfile:
dest: /etc/default/docker
regexp: "^export HTTPS_PROXY="
line: "export HTTPS_PROXY=\"{{docker_https_proxy}}\""
state: present
when: docker_https_proxy is defined and (docker_https_proxy != None)
notify:
- Restart docker
tags: proxy

- name: Start docker
service:
name: docker
Expand Down

0 comments on commit 0af1f02

Please sign in to comment.