add support for proxy inside containers

This commit is contained in:
Adrian Bienkowski 2020-06-15 06:07:28 -04:00
parent fa52c5f28b
commit 17c9f9a080
6 changed files with 40 additions and 1 deletions

View File

@ -1,3 +1,11 @@
---
- name: reload systemd
systemd:
daemon_reload: yes
become: yes
- name: restart docker
service: "name=docker state={{ docker_restart_handler_state }}"
service:
name: docker
state: "{{ docker_restart_handler_state }}"
become: yes

View File

@ -0,0 +1,17 @@
---
- name: create a service directory
file:
path: /etc/systemd/system/docker.service.d
state: directory
- name: add proxy configuration for docker service
template:
dest: "/etc/systemd/system/docker.service.d/{{ item }}.conf"
src: "{{ item }}.conf.j2"
with_items:
- http_proxy
- https_proxy
- no_proxy
notify:
- reload systemd
- restart docker

View File

@ -11,6 +11,13 @@
state: "{{ docker_package_state }}"
notify: restart docker
- include_tasks: docker-service-proxy.yml
when:
- http_proxy is defined
- https_proxy is defined
- no_proxy is defined
- enable_proxy is defined and enable_proxy|bool
- name: Ensure Docker is started and enabled at boot.
service:
name: docker
@ -25,3 +32,4 @@
- include_tasks: docker-users.yml
when: docker_users | length > 0

View File

@ -0,0 +1,2 @@
[Service]
Environment="HTTP_PROXY={{ http_proxy }}"

View File

@ -0,0 +1,2 @@
[Service]
Environment="HTTPS_PROXY={{ https_proxy }}"

View File

@ -0,0 +1,2 @@
[Service]
Environment="NO_PROXY={{ no_proxy }}"