Finished lb and db

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
Tuan-Dat Tran
2024-09-19 23:10:00 +02:00
parent 50abbf933c
commit 51a49d003d
51 changed files with 384 additions and 367 deletions

View File

@@ -0,0 +1,6 @@
---
- name: Restart nginx
systemd:
name: nginx
state: restarted
become: true

View File

@@ -0,0 +1,20 @@
---
- name: Template the nginx config file with dynamic upstreams
template:
src: templates/nginx.conf.j2
dest: "{{ nginx_config_path }}"
owner: root
group: root
mode: "0644"
become: true
notify:
- Restart nginx
vars:
k3s_server_ips: "{{ k3s.server.ips }}"
- name: Enable nginx
systemd:
name: nginx
daemon_reload: true
enabled: true
become: true

View File

@@ -0,0 +1,12 @@
---
- name: Update apt cache
apt:
update_cache: yes
become: true
- name: Install Nginx
apt:
name:
- nginx-full
state: present
become: true

View File

@@ -0,0 +1,3 @@
---
- include_tasks: installation.yml
- include_tasks: configuration.yml

View File

@@ -0,0 +1,16 @@
include /etc/nginx/modules-enabled/*.conf;
events {}
stream {
upstream k3s_servers {
{% for ip in k3s_server_ips %}
server {{ ip }}:6443;
{% endfor %}
}
server {
listen 6443;
proxy_pass k3s_servers;
}
}

View File

@@ -0,0 +1 @@
nginx_config_path: "/etc/nginx/nginx.conf"