Skip to content

Commit

Permalink
Proxy Configuration Added
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidyousefi committed Nov 3, 2020
1 parent 138d8b4 commit 7cd0b5c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ define which version you are going to use just by replacing it with something li
You can find the versions list and their changelogs from [releases page](https://github.com/hamidyousefi/ansible-docker/releases).

## Additional Extensions and Configurations
I added two specific extra feature to this role. `docker-compose` and `iptables` can be set up easily just
I added three specific extra feature to this role. `docker-compose` and `iptables` can be set up easily just
by adding the below block in your `group_vars` related YAML file:
```yaml
configure:
compose: yes
iptables: yes
proxy: no
```

## HTTP(S) Proxies
If you have to configure http and (or) https proxy on your docker, you can change
the ```proxy``` parameter in above section from ```no``` to ```yes```, and add below
variables into necessary host or group variables.
```yaml
docker_proxy:
http: 'http://your-server:80'
https: 'https://your-server:443'
```
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ extensions:
configure:
compose: no
iptables: no
proxy: no

docker_proxy:
http: 'http://server:80'
https: 'https://server:443'
19 changes: 19 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,24 @@
mode: '0655'
when: configure.compose

- name: configure proxy if defined
block:
- name: create systemd necessary directory
file:
path: /etc/systemd/system/docker.service.d
state: directory
owner: root
group: root
mode: '0755'

- name: create systemd service config file
template:
src: proxy.conf.j2
dest: /etc/systemd/system/docker.service.d/proxy.conf
owner: root
group: root
mode: '0644'
when: configure.proxy

- include: iptables.yml
when: configure.iptables
3 changes: 3 additions & 0 deletions templates/proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Service]
Environment="HTTP_PROXY={{ docker_proxy.http }}"
Environment="HTTPS_PROXY={{ docker_proxy.https }}"

0 comments on commit 7cd0b5c

Please sign in to comment.