Add proxy configuration.

This commit is contained in:
Walid Shouman 2019-11-18 10:29:29 +00:00
parent 416c0c9a06
commit 817285395e
4 changed files with 29 additions and 0 deletions

View File

@ -27,3 +27,8 @@ docker_yum_repo_enable_test: 0
# A list of users who will be added to the docker group.
docker_users: []
# proxy settings
http_proxy: ""
https_proxy: ""
no_proxy: ""

16
tasks/docker-service.yml Normal file
View File

@ -0,0 +1,16 @@
---
- name: Ensure docker service dir exists.
file:
path: /etc/systemd/system/docker.service.d
state: directory
- name: Add Docker configuration with proxy set.
template:
src: proxy.conf.j2
dest: /etc/systemd/system/docker.service.d/proxy.conf
register: proxy_template
- name: Reload systemd daemon if template is changed.
systemd:
daemon_reload: true
when: proxy_template is changed

View File

@ -15,6 +15,9 @@
- import_tasks: docker-1809-shim.yml
when: ansible_service_mgr == 'systemd'
- import_tasks: docker-service.yml
when: ansible_service_mgr == 'systemd'
- name: Ensure Docker is started and enabled at boot.
service:
name: docker

5
templates/proxy.conf.j2 Normal file
View File

@ -0,0 +1,5 @@
# {{ ansible_managed }}
[Service]
Environment='HTTP_PROXY={{ http_proxy }}'
Environment='HTTPS_PROXY={{ https_proxy }}'
Environment='NO_PROXY={{ no_proxy }}'