Added pre-role for k3s and frigate

This commit is contained in:
2022-11-10 21:01:15 +00:00
parent 9a7c540c7e
commit f783d35513
17 changed files with 191 additions and 175 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
[defaults] [defaults]
nocows = True nocows = True
roles_path = ./roles roles_path = ./roles
inventory = ./hosts.ini inventory = ./inventory/my-cluster/hosts.ini
stdout_callback = yaml stdout_callback = yaml
remote_tmp = $HOME/.ansible/tmp remote_tmp = $HOME/.ansible/tmp
@@ -20,4 +20,4 @@ scp_if_ssh = smart
retries = 3 retries = 3
ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o Compression=yes -o ServerAliveInterval=15s ssh_args = -o ControlMaster=auto -o ControlPersist=30m -o Compression=yes -o ServerAliveInterval=15s
pipelining = True pipelining = True
control_path = %(directory)s/%%h-%%r control_path = %(directory)s/%%h-%%r
+16
View File
@@ -49,3 +49,19 @@ metal_lb_controller_tag_version: "v0.13.6"
# metallb ip range for load balancer # metallb ip range for load balancer
metal_lb_ip_range: "10.1.1.2-10.1.1.254" metal_lb_ip_range: "10.1.1.2-10.1.1.254"
lxc_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
38303735306236303463613632623161643633663631303931396564346565666236643562316264
6533643331306364653564653763356537303932313531350a393261643137636232616335376461
66383966333765626539363561613361393665616333303964373761356166623766663232303063
3138353333373935660a383230393330646538303933336366383736643333623663333934663131
3064
proxmox_api_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
35376334616332386130656335663736343337396532663266383934643632363664646631653935
6533343936353734343761343465646365616130643130360a316234333036303738663566666364
61653638373830383733323563373862346662363339656632643661336533363162616435616531
6331326462356366320a303331616366356333306638386130666538633833623162653934616338
3566
+11
View File
@@ -0,0 +1,11 @@
---
mac_addr: de:05:ff:02:47:d7
hostname: k3s-master-epona
ip_addr: 10.0.2.2
lxc_host: 10.0.3.2
cores: 4
memory: 8192
disk: 75
vmid: 601
ansible_user: root
@@ -2,8 +2,8 @@
mac_addr: ee:36:d5:79:f8:ff mac_addr: ee:36:d5:79:f8:ff
node: urbosa node: urbosa
ansible_host: 10.0.3.3 lxc_host: 10.0.3.3
cores: 3 cores: 3
memory: 2048 memory: 2048
disk: 80G disk: 8
vmid: 604 vmid: 604
@@ -1,9 +0,0 @@
---
mac_addr: 32:47:89:3f:1a:e2
node: revali
ansible_host: 10.0.3.4
cores: 2
memory: 4096
disk: 200G
vmid: 603
@@ -1,9 +0,0 @@
---
mac_addr: de:05:ff:02:47:d7
node: epona
ansible_host: 10.0.3.2
cores: 4
memory: 8192
disk: 75G
vmid: 601
@@ -1,9 +0,0 @@
---
mac_addr: 0e:a0:ff:8c:70:df
node: mipha
ansible_host: 10.0.3.1
cores: 4
memory: 6144
disk: 75G
vmid: 602
+11
View File
@@ -0,0 +1,11 @@
---
mac_addr: 0e:a0:ff:8c:70:df
hostname: k3s-master-mipha
ip_addr: 10.0.2.3
lxc_host: 10.0.3.1
cores: 4
memory: 6144
disk: 75
vmid: 602
ansible_user: root
+11
View File
@@ -0,0 +1,11 @@
---
mac_addr: 32:47:89:3f:1a:e2
hostname: k3s-agent-revali
ip_addr: 10.0.2.4
lxc_host: 10.0.3.4
cores: 2
memory: 4096
disk: 200
vmid: 603
ansible_user: root
+11
View File
@@ -0,0 +1,11 @@
---
mac_addr: ee:36:d5:79:f8:ff
hostname: k3s-agent-urbosa
ip_addr: 10.0.2.5
lxc_host: 10.0.3.3
cores: 3
memory: 2048
disk: 80
vmid: 604
ansible_user: root
+11 -4
View File
@@ -1,7 +1,14 @@
[frigate]
frigate
[master] [master]
k3s-server-mipha mipha
k3s-server-epona epona
[node] [node]
k3s-agent-urbosa urbosa
k3s-agent-revali revali
[k3s_cluster:children]
master
node
-51
View File
@@ -1,51 +0,0 @@
---
k3s_version: v1.24.6+k3s1
# this is the user that has ssh access to these machines
ansible_user: ansibleuser
systemd_dir: /etc/systemd/system
# Set your timezone
system_timezone: "Your/Timezone"
# interface which will be used for flannel
flannel_iface: "eth0"
# apiserver_endpoint is virtual ip-address which will be configured on each master
apiserver_endpoint: "192.168.30.222"
# k3s_token is required masters can talk together securely
# this token should be alpha numeric only
k3s_token: "some-SUPER-DEDEUPER-secret-password"
# The IP on which the node is reachable in the cluster.
# Here, a sensible default is provided, you can still override
# it for each of your hosts, though.
k3s_node_ip: '{{ ansible_facts[flannel_iface]["ipv4"]["address"] }}'
# Disable the taint manually by setting: k3s_master_taint = false
k3s_master_taint: "{{ true if groups['node'] | default([]) | length >= 1 else false }}"
# these arguments are recommended for servers as well as agents:
extra_args: >-
--flannel-iface={{ flannel_iface }}
--node-ip={{ k3s_node_ip }}
# change these to your liking, the only required are: --disable servicelb, --tls-san {{ apiserver_endpoint }}
extra_server_args: >-
{{ extra_args }}
{{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }}
--tls-san {{ apiserver_endpoint }}
--disable servicelb
--disable traefik
extra_agent_args: >-
{{ extra_args }}
# image tag for kube-vip
kube_vip_tag_version: "v0.5.5"
# image tag for metal lb
metal_lb_speaker_tag_version: "v0.13.6"
metal_lb_controller_tag_version: "v0.13.6"
# metallb ip range for load balancer
metal_lb_ip_range: "192.168.30.80-192.168.30.90"
-12
View File
@@ -1,12 +0,0 @@
[master]
192.168.30.38
192.168.30.39
192.168.30.40
[node]
192.168.30.41
192.168.30.42
[k3s_cluster:children]
master
node
+56
View File
@@ -0,0 +1,56 @@
---
- name: Create LXC for frigate
hosts: localhost
gather_facts: yes
tasks:
- name: Stop container
community.general.proxmox:
vmid: 200
api_user: root@pam
api_password: {{ proxmox_api_password }}
api_host: 10.0.2.2
state: stopped
ignore_errors: yes
- name: Remove container
community.general.proxmox:
vmid: 200
api_user: root@pam
api_password: {{ proxmox_api_password }}
api_host: 10.0.2.2
state: absent
ignore_errors: yes
- name: Create container
community.general.proxmox:
vmid: 200
node: epona
api_user: root@pam
api_password: {{ proxmox_api_password }}
api_host: 10.0.2.2
password: {{ lxc_password }}
hostname: frigate
ostemplate: "hyrule-8tb-nfs:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst"
netif: "{'net0':'name=eth0,\
gw=10.0.0.1,\
ip=10.0.2.14/21,\
hwaddr=62:67:fc:7a:58:01,\
bridge=vmbr0'}"
cores: "2"
memory: "2048"
unprivileged: no
swap: 0
searchdomain: "home"
onboot: 1
disk: local-lvm:8
mounts: '{"mp0":"hyrule-8tb-nfs:500,mp=/media/frigate"}'
mounts: '{"mp1":"/dev/bus/usb,mp=/dev/bus/usb"}'
force: yes
- name: Start deployment
community.general.proxmox:
vmid: 200
api_user: root@pam
api_password: {{ proxmox_api_password }}
api_host: 10.0.2.2
state: started
+57
View File
@@ -0,0 +1,57 @@
---
- name: Get uptime information
ansible.builtin.shell: /usr/bin/uptime
- name: Stop containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: stopped
loop: "{{ groups['k3s_cluster'] }}"
ignore_errors: true
- name: Remove containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: "{{ hostvars[item]['ip_addr'] }}"
state: absent
loop: "{{ groups['k3s_cluster'] }}"
ignore_errors: true
- name: Create containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
node: "{{ item }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
password: "{{ lxc_password }}"
hostname: "{{ hostvars[item]['hostname'] }}"
ostemplate: "hyrule-8tb-nfs:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst"
netif: "{'net0':'name=eth0,\
gw=10.0.0.1,\
ip={{ hostvars[item]['lxc_host'] }}/21,\
hwaddr={{ hostvars[item]['mac_addr'] }},\
bridge=vmbr0'}"
cores: "{{ hostvars[item]['cores'] }}"
memory: "{{ hostvars[item]['memory'] }}"
unprivileged: no
swap: 0
searchdomain: "home"
onboot: 1
disk: local-lvm:{{ hostvars[item]['disk'] }}
force: yes
loop: "{{ groups['k3s_cluster'] }}"
- name: Start deployments
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: started
loop: "{{ groups['k3s_cluster'] }}"
-58
View File
@@ -1,58 +0,0 @@
---
- name: Create LXC for k3s
hosts: localhost
gather_facts: no
tasks:
- name: Stop containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
state: stopped
loop: "{{ groups['all'] }}"
ignore_errors: yes
- name: Remove containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
state: absent
loop: "{{ groups['all'] }}"
ignore_errors: yes
- name: Create containers
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
node: "{{ hostvars[item]['node'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
password: bemjogado
hostname: "{{ item }}"
ostemplate: "hyrule-8tb-nfs:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst"
netif: "{'net0':'name=eth0,\
gw=10.0.0.1,\
ip={{ hostvars[item]['ansible_host'] }}/21,\
hwaddr={{ hostvars[item]['mac_addr'] }},\
bridge=vmbr0'}"
cores: "{{ hostvars[item]['cores'] }}"
memory: "{{ hostvars[item]['memory'] }}"
unprivileged: no
swap: 0
searchdomain: "home"
onboot: 1
disk: local-lvm:8
force: yes
loop: "{{ groups['all'] }}"
- name: Start deployments
community.general.proxmox:
vmid: "{{ hostvars[item]['vmid'] }}"
api_user: root@pam
api_password: bemjogado
api_host: 10.0.2.2
state: started
loop: "{{ groups['all'] }}"
+3 -19
View File
@@ -1,22 +1,6 @@
--- ---
- hosts: k3s_cluster - hosts: localhost
gather_facts: yes gather_facts: no
become: yes become: yes
roles: roles:
- role: prereq - role: k3s/pre
- role: download
- hosts: master
become: yes
roles:
- role: k3s/master
- hosts: node
become: yes
roles:
- role: k3s/node
- hosts: master
become: yes
roles:
- role: k3s/post