File tree Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ Add to you playbook.yml
2+
3+ ``` yaml
4+ - hosts : docker
5+ gather_facts : yes
6+ become : yes
7+ become_method : sudo
8+ vars :
9+ docker_proxy_url : 192.168.66.72 # you proxy url
10+ roles :
11+ - role : docker-proxy
12+ ` ` `
Original file line number Diff line number Diff line change 1+ docker_proxy_url : 192.168.66.72
Original file line number Diff line number Diff line change 1+ - name : Get the CA certificate from the proxy and make it a trusted root.
2+ get_url :
3+ url : http://{{ docker_proxy_url }}:3128/ca.crt
4+ dest : /etc/pki/ca-trust/source/anchors/docker_registry_proxy.crt
5+ mode : ' 0644'
6+ - name : update trusted ca redhat
7+ shell : /bin/update-ca-trust
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Ensures docker.service.d dir exists
3+ file : >
4+ path=/etc/systemd/system/docker.service.d
5+ recurse=yes
6+ state=directory
7+ - name : Add environment vars pointing Docker to use the proxy
8+ copy :
9+ dest : /etc/systemd/system/docker.service.d/http-proxy.conf
10+ content : |
11+ [Service]
12+ Environment="HTTP_PROXY=http://{{ docker_proxy_url }}:3128/"
13+ Environment="HTTPS_PROXY=http://{{ docker_proxy_url }}:3128/"
14+
15+ - name : Include ubuntu tasks
16+ include_tasks : ubuntu.yml
17+ when : ansible_os_family == "Debian"
18+
19+ - name : Include centos tasks
20+ include_tasks : centos.yml
21+ when : ansible_os_family == "RedHat"
22+
23+ - name : Just force systemd to reread configs (2.4 and above)
24+ ansible.builtin.systemd :
25+ daemon_reload : yes
26+
27+ - name : Reload service docker, in all cases
28+ ansible.builtin.systemd :
29+ name : docker.service
30+ state : reloaded
Original file line number Diff line number Diff line change 1+ - name : Get the CA certificate from the proxy and make it a trusted root.
2+ get_url :
3+ url : http://{{ docker_proxy_url }}:3128/ca.crt
4+ dest : /usr/share/ca-certificates/docker_registry_proxy.crt
5+ mode : ' 0644'
6+
7+ - name : update trusted ca
8+ shell : /usr/sbin/update-ca-certificates --fresh
You can’t perform that action at this time.
0 commit comments