Skip to content

Commit

Permalink
Tidy up http_proxy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
balazshasprai committed Oct 20, 2023
1 parent ce546b7 commit cfc553b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 33 deletions.
8 changes: 4 additions & 4 deletions inventory/sample/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ custom_registries_yaml: |
password: yourpassword
# Only enable and configure these if you access the internet through a proxy
http_proxy_configure: false
http_proxy: "http://proxy.domain.local:3128"
https_proxy: "http://proxy.domain.local:3128"
no_proxy: "*.domain.local,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
# proxy_env:
# HTTP_PROXY: "http://proxy.domain.local:3128"
# HTTPS_PROXY: "http://proxy.domain.local:3128"
# NO_PROXY: "*.domain.local,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
2 changes: 1 addition & 1 deletion roles/k3s_agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: http_proxy_configure | default(false)
when: proxy_env is defined

- name: Copy K3s service file
template:
Expand Down
6 changes: 3 additions & 3 deletions roles/k3s_agent/templates/http_proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Service]
Environment=HTTP_PROXY={{ http_proxy }}
Environment=HTTPS_PROXY={{ https_proxy }}
Environment=NO_PROXY={{ no_proxy }}
Environment=HTTP_PROXY={{ proxy_env.HTTP_PROXY }}
Environment=HTTPS_PROXY={{ proxy_env.HTTPS_PROXY }}
Environment=NO_PROXY={{ proxy_env.NO_PROXY }}
2 changes: 1 addition & 1 deletion roles/k3s_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: http_proxy_configure | default(false)
when: proxy_env is defined

- name: Deploy vip manifest
include_tasks: vip.yml
Expand Down
6 changes: 3 additions & 3 deletions roles/k3s_server/templates/http_proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Service]
Environment=HTTP_PROXY={{ http_proxy }}
Environment=HTTPS_PROXY={{ https_proxy }}
Environment=NO_PROXY={{ no_proxy }}
Environment=HTTP_PROXY={{ proxy_env.HTTP_PROXY }}
Environment=HTTPS_PROXY={{ proxy_env.HTTPS_PROXY }}
Environment=NO_PROXY={{ proxy_env.NO_PROXY }}
2 changes: 1 addition & 1 deletion roles/reset/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
with_items:
- "{{ systemd_dir }}/k3s.service.d"
- "{{ systemd_dir }}/k3s-node.service.d"
when: http_proxy_configure | default(false)
when: proxy_env is defined

- name: Reload daemon_reload
systemd:
Expand Down
25 changes: 5 additions & 20 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@
hosts: proxmox
gather_facts: true
become: yes
environment:
HTTP_PROXY: "{{ http_proxy | default('') }}"
HTTPS_PROXY: "{{ https_proxy | default('') }}"
NO_PROXY: "{{ no_proxy | default('') }}"
environment: "{{ proxy_env | default({}) }}"
roles:
- role: proxmox_lxc
when: proxmox_lxc_configure

- name: Prepare k3s nodes
hosts: k3s_cluster
gather_facts: yes
environment:
HTTP_PROXY: "{{ http_proxy | default('') }}"
HTTPS_PROXY: "{{ https_proxy | default('') }}"
NO_PROXY: "{{ no_proxy | default('') }}"
environment: "{{ proxy_env | default({}) }}"
roles:
- role: lxc
become: true
Expand All @@ -34,30 +28,21 @@

- name: Setup k3s servers
hosts: master
environment:
HTTP_PROXY: "{{ http_proxy | default('') }}"
HTTPS_PROXY: "{{ https_proxy | default('') }}"
NO_PROXY: "{{ no_proxy | default('') }}"
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server
become: true

- name: Setup k3s agents
hosts: node
environment:
HTTP_PROXY: "{{ http_proxy | default('') }}"
HTTPS_PROXY: "{{ https_proxy | default('') }}"
NO_PROXY: "{{ no_proxy | default('') }}"
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_agent
become: true

- name: Configure k3s cluster
hosts: master
environment:
HTTP_PROXY: "{{ http_proxy | default('') }}"
HTTPS_PROXY: "{{ https_proxy | default('') }}"
NO_PROXY: "{{ no_proxy | default('') }}"
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server_post
become: true

0 comments on commit cfc553b

Please sign in to comment.