Skip to content

Commit

Permalink
Refactored to tasks as per review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Klijn <[email protected]>
  • Loading branch information
peterklijn committed Jul 13, 2024
1 parent 4c31a36 commit 9325d9d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
6 changes: 0 additions & 6 deletions roles/k3s_server/handlers/main.yml

This file was deleted.

30 changes: 26 additions & 4 deletions roles/k3s_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
owner: root
group: root
mode: "0644"
notify: Restart K3s Server
register: service_file_single

- name: Copy K3s service file [HA]
when:
Expand All @@ -77,7 +77,7 @@
owner: root
group: root
mode: "0644"
notify: Restart K3s Server
register: service_file_ha

- name: Add service environment variables
when: extra_service_envs is defined
Expand All @@ -86,7 +86,18 @@
line: "{{ item }}"
with_items: "{{ extra_service_envs }}"

- name: Restart K3s service
when:
- ansible_facts.services['k3s.service'] is defined
- ansible_facts.services['k3s.service'].state == 'running'
- service_file_single.changed or service_file_ha.changed
ansible.builtin.systemd:
name: k3s
daemon_reload: true
state: restarted

- name: Enable and check K3s service
when: ansible_facts.services['k3s.service'] is not defined or ansible_facts.services['k3s.service'].state != 'running'
ansible.builtin.systemd:
name: k3s
daemon_reload: true
Expand Down Expand Up @@ -161,7 +172,7 @@
owner: root
group: root
mode: "0644"
notify: Restart K3s Server
register: service_file_ha

- name: Copy K3s service file [External DB]
when:
Expand All @@ -173,9 +184,20 @@
owner: root
group: root
mode: "0644"
notify: Restart K3s Server
register: service_file_external_db

- name: Restart K3s service
when:
- ansible_facts.services['k3s.service'] is defined
- ansible_facts.services['k3s.service'].state == 'running'
- service_file_ha.changed or service_file_external_db.changed
ansible.builtin.systemd:
name: k3s
daemon_reload: true
state: restarted

- name: Enable and check K3s service
when: ansible_facts.services['k3s.service'] is not defined or ansible_facts.services['k3s.service'].state != 'running'
ansible.builtin.systemd:
name: k3s
daemon_reload: true
Expand Down

0 comments on commit 9325d9d

Please sign in to comment.