Skip to content

Commit

Permalink
fix containerd proxy not setting
Browse files Browse the repository at this point in the history
  • Loading branch information
buxiaomo committed Nov 14, 2024
1 parent d3fd273 commit 3371775
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions roles/containerd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,26 @@
- upgrade
- update

- name: Create systemd service.d
ansible.builtin.file:
name: /etc/systemd/system/containerd.service.d
state: directory
mode: "0755"
when: proxy_env is defined
notify: restart containerd
tags:
- update

- name: Install systemd file proxy.conf
ansible.builtin.template:
src: proxy.conf.j2
dest: /etc/systemd/system/containerd.service.d/proxy.conf
register: containerd_systemd_d
when: proxy_env is defined
notify: restart containerd
tags:
- update

- name: Populate service facts
ansible.builtin.service_facts:

Expand All @@ -202,6 +222,7 @@
crictl_pkg.changed or
containerd_cfg.changed or
containerd_systemd.changed or
containerd_systemd_d.changed or
ansible_facts.services['containerd.service']['state'] != 'running'

- name: Install crictl completion
Expand Down
12 changes: 12 additions & 0 deletions roles/containerd/templates/proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% if proxy_env is defined %}
{% if proxy_env.http_proxy is defined and proxy_env.http_proxy != "" %}
[Service]
Environment="HTTP_PROXY={{ proxy_env.http_proxy }}"
{% endif %}
{% if proxy_env.https_proxy is defined and proxy_env.https_proxy != "" %}
Environment="HTTPS_PROXY={{ proxy_env.https_proxy }}"
{% endif %}
{% if proxy_env.no_proxy is defined and proxy_env.no_proxy != "" %}
Environment="NO_PROXY={{ proxy_env.no_proxy }}"
{% endif %}
{% endif %}

0 comments on commit 3371775

Please sign in to comment.