refactor(k3s): streamline inventory and primary server IP handling
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
20
roles/k3s_loadbalancer/tasks/configuration.yml
Normal file
20
roles/k3s_loadbalancer/tasks/configuration.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Template the nginx config file with dynamic upstreams
|
||||
ansible.builtin.template:
|
||||
src: templates/nginx.conf.j2
|
||||
dest: "{{ k3s_loadbalancer_nginx_config_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
become: true
|
||||
notify:
|
||||
- Restart nginx
|
||||
vars:
|
||||
k3s_server_ips: "{{ groups['k3s_server'] | map('extract', hostvars, 'ansible_default_ipv4') | map(attribute='address') | unique | list }}"
|
||||
|
||||
- name: Enable nginx
|
||||
ansible.builtin.systemd:
|
||||
name: nginx
|
||||
daemon_reload: true
|
||||
enabled: true
|
||||
become: true
|
||||
12
roles/k3s_loadbalancer/tasks/installation.yml
Normal file
12
roles/k3s_loadbalancer/tasks/installation.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
become: true
|
||||
|
||||
- name: Install Nginx
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- nginx-full
|
||||
state: present
|
||||
become: true
|
||||
5
roles/k3s_loadbalancer/tasks/main.yml
Normal file
5
roles/k3s_loadbalancer/tasks/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Installation
|
||||
ansible.builtin.include_tasks: installation.yml
|
||||
- name: Configure
|
||||
ansible.builtin.include_tasks: configuration.yml
|
||||
Reference in New Issue
Block a user