blob: e26fa742a31c73108bf5e067aa12c38a43911fd8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
---
- name: make sure kubernetes_network_plugin_replaces_kube_proxy is not set
run_once: yes
assert:
msg: "kubeguard can not replace kube-proxy, please set kubernetes_network_plugin_replaces_kube_proxy to false."
that: not kubernetes_network_plugin_replaces_kube_proxy
- name: install wireguard
import_role:
name: network/wireguard/base
- name: create network config directory
file:
name: /var/lib/kubeguard/
state: directory
- name: install ifupdown script
template:
src: net_kubeguard/ifupdown.sh.j2
dest: /var/lib/kubeguard/ifupdown.sh
mode: 0755
# TODO: notify reload... this is unfortunately already to late because
# it must probably be brought down by the old version of the script
- name: generate wireguard private key
shell: "umask 077; wg genkey > /var/lib/kubeguard/kubeguard-wg0.privatekey"
args:
creates: /var/lib/kubeguard/kubeguard-wg0.privatekey
- name: fetch wireguard public key
shell: "wg pubkey < /var/lib/kubeguard/kubeguard-wg0.privatekey"
register: kubeguard_wireguard_pubkey
changed_when: false
check_mode: no
- name: install systemd service unit for network interface
template:
src: net_kubeguard/interface.service.j2
dest: /etc/systemd/system/kubeguard-interface.service
# TODO: notify: reload???
- name: make sure kubeguard interface service is started and enabled
systemd:
daemon_reload: yes
name: kubeguard-interface.service
state: started
enabled: yes
- name: install systemd units for every kubeguard peer
loop: "{{ groups['_kubernetes_nodes_'] | difference(inventory_hostname) }}"
loop_control:
loop_var: peer
template:
src: net_kubeguard/peer.service.j2
dest: "/etc/systemd/system/kubeguard-peer-{{ peer }}.service"
# TODO: notify restart for peers that change...
- name: make sure kubeguard peer services are started and enabled
loop: "{{ groups['_kubernetes_nodes_'] | difference(inventory_hostname) }}"
systemd:
daemon_reload: yes
name: "kubeguard-peer-{{ item }}.service"
state: started
enabled: yes
- name: enable IPv4 forwarding
sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: yes
state: present
reload: yes
- name: create cni config directory
file:
name: /etc/cni/net.d
state: directory
- name: install cni config
template:
src: net_kubeguard/cni.conflist.j2
dest: /etc/cni/net.d/kubeguard.conflist
|