add set-containerd-proxy.yaml
This commit is contained in:
39
set-contained-proxy.yaml
Normal file
39
set-contained-proxy.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
- name: Configure HTTP proxy for containerd
|
||||
hosts: all
|
||||
become: yes
|
||||
user: root
|
||||
tasks:
|
||||
- name: Check if kubelet service is running
|
||||
shell: systemctl is-active kubelet
|
||||
register: kubelet_status
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Create directory for containerd service override
|
||||
file:
|
||||
path: /etc/systemd/system/containerd.service.d
|
||||
state: directory
|
||||
when: kubelet_status.stdout == "active"
|
||||
|
||||
- name: Create or edit http-proxy.conf for containerd
|
||||
blockinfile:
|
||||
path: /etc/systemd/system/containerd.service.d/http-proxy.conf
|
||||
create: yes
|
||||
block: |
|
||||
[Service]
|
||||
Environment="HTTP_PROXY=http://192.168.1.38:7890"
|
||||
Environment="HTTPS_PROXY=http://192.168.1.38:7890"
|
||||
Environment="NO_PROXY=localhost"
|
||||
when: kubelet_status.stdout == "active"
|
||||
|
||||
- name: Reload systemd daemon
|
||||
command: systemctl daemon-reload
|
||||
when: kubelet_status.stdout == "active"
|
||||
|
||||
- name: Restart containerd and kubelet services
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
loop:
|
||||
- containerd
|
||||
- kubelet
|
||||
when: kubelet_status.stdout == "active"
|
||||
Reference in New Issue
Block a user