Add option for install behind http_proxy (#384)
* Add option for install behind http_proxy * Tidy up http_proxy usage
This commit is contained in:
parent
95b2836dfc
commit
e880f08d26
@ -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
roles/k3s_agent/tasks/http_proxy.yml
Normal file
18
roles/k3s_agent/tasks/http_proxy.yml
Normal file
@ -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'
|
||||
@ -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"
|
||||
|
||||
4
roles/k3s_agent/templates/http_proxy.conf.j2
Normal file
4
roles/k3s_agent/templates/http_proxy.conf.j2
Normal file
@ -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
roles/k3s_server/tasks/http_proxy.yml
Normal file
18
roles/k3s_server/tasks/http_proxy.yml
Normal file
@ -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'
|
||||
@ -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
|
||||
|
||||
|
||||
4
roles/k3s_server/templates/http_proxy.conf.j2
Normal file
4
roles/k3s_server/templates/http_proxy.conf.j2
Normal file
@ -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 }}
|
||||
@ -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
|
||||
|
||||
5
site.yml
5
site.yml
@ -3,6 +3,7 @@
|
||||
hosts: proxmox
|
||||
gather_facts: true
|
||||
become: yes
|
||||
environment: "{{ proxy_env | default({}) }}"
|
||||
roles:
|
||||
- role: proxmox_lxc
|
||||
when: proxmox_lxc_configure
|
||||
@ -10,6 +11,7 @@
|
||||
- name: Prepare k3s nodes
|
||||
hosts: k3s_cluster
|
||||
gather_facts: yes
|
||||
environment: "{{ proxy_env | default({}) }}"
|
||||
roles:
|
||||
- role: lxc
|
||||
become: true
|
||||
@ -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…
Reference in New Issue
Block a user