Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for install behind http_proxy #384

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions inventory/sample/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,9 @@ custom_registries_yaml: |
auth:
username: yourusername
password: yourpassword

# Only enable and configure these if you access the internet through a proxy
# 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"
18 changes: 18 additions & 0 deletions roles/k3s_agent/tasks/http_proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- name: Create k3s.service.d directory
file:
path: '{{ systemd_dir }}/k3s.service.d'
state: directory
owner: root
group: root
mode: '0755'


- name: Copy K3s http_proxy conf file
template:
src: "http_proxy.conf.j2"
dest: "{{ systemd_dir }}/k3s.service.d/http_proxy.conf"
owner: root
group: root
mode: '0755'
4 changes: 4 additions & 0 deletions roles/k3s_agent/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---

- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: proxy_env is defined

- name: Copy K3s service file
template:
src: "k3s.service.j2"
Expand Down
4 changes: 4 additions & 0 deletions roles/k3s_agent/templates/http_proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Service]
Environment=HTTP_PROXY={{ proxy_env.HTTP_PROXY }}
Environment=HTTPS_PROXY={{ proxy_env.HTTPS_PROXY }}
Environment=NO_PROXY={{ proxy_env.NO_PROXY }}
18 changes: 18 additions & 0 deletions roles/k3s_server/tasks/http_proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- name: Create k3s.service.d directory
file:
path: '{{ systemd_dir }}/k3s.service.d'
state: directory
owner: root
group: root
mode: '0755'


- name: Copy K3s http_proxy conf file
template:
src: "http_proxy.conf.j2"
dest: "{{ systemd_dir }}/k3s.service.d/http_proxy.conf"
owner: root
group: root
mode: '0755'
4 changes: 4 additions & 0 deletions roles/k3s_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
failed_when: false
changed_when: false

- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: proxy_env is defined

- name: Deploy vip manifest
include_tasks: vip.yml

Expand Down
4 changes: 4 additions & 0 deletions roles/k3s_server/templates/http_proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Service]
Environment=HTTP_PROXY={{ proxy_env.HTTP_PROXY }}
Environment=HTTPS_PROXY={{ proxy_env.HTTPS_PROXY }}
Environment=NO_PROXY={{ proxy_env.NO_PROXY }}
9 changes: 9 additions & 0 deletions roles/reset/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
- /var/lib/rancher/
- /var/lib/cni/

- name: Remove K3s http_proxy files
file:
name: "{{ item }}"
state: absent
with_items:
- "{{ systemd_dir }}/k3s.service.d"
- "{{ systemd_dir }}/k3s-node.service.d"
when: proxy_env is defined

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

- name: Prepare k3s nodes
hosts: k3s_cluster
gather_facts: yes
environment: "{{ proxy_env | default({}) }}"
roles:
- role: lxc
become: true
Expand All @@ -26,18 +28,21 @@

- name: Setup k3s servers
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server
become: true

- name: Setup k3s agents
hosts: node
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_agent
become: true

- name: Configure k3s cluster
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server_post
become: true
Loading