mirror of
https://github.com/geerlingguy/ansible-role-docker.git
synced 2025-08-15 13:48:28 +02:00
add support for proxy inside containers
This commit is contained in:
parent
fa52c5f28b
commit
17c9f9a080
@ -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
|
||||
|
17
tasks/docker-service-proxy.yml
Normal file
17
tasks/docker-service-proxy.yml
Normal 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
|
@ -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
|
||||
|
||||
|
2
templates/http_proxy.conf.j2
Normal file
2
templates/http_proxy.conf.j2
Normal file
@ -0,0 +1,2 @@
|
||||
[Service]
|
||||
Environment="HTTP_PROXY={{ http_proxy }}"
|
2
templates/https_proxy.conf.j2
Normal file
2
templates/https_proxy.conf.j2
Normal file
@ -0,0 +1,2 @@
|
||||
[Service]
|
||||
Environment="HTTPS_PROXY={{ https_proxy }}"
|
2
templates/no_proxy.conf.j2
Normal file
2
templates/no_proxy.conf.j2
Normal file
@ -0,0 +1,2 @@
|
||||
[Service]
|
||||
Environment="NO_PROXY={{ no_proxy }}"
|
Loading…
Reference in New Issue
Block a user