prole/infrastructure/roles/k3s/tasks/start_k3s_servers.yml

22 lines
621 B
YAML

---
- name: Gather service facts
ansible.builtin.service_facts:
- name: Require k3s service to exist
ansible.builtin.assert:
that:
- ('k3s' + '.service') in ansible_facts.services
- ansible_facts.services['k3s' + '.service'].status != 'not-found'
fail_msg: "k3s service is not installed on {{ inventory_hostname }}."
when: not ansible_check_mode
- name: Start k3s
ansible.builtin.systemd:
name: k3s
state: started
enabled: true
no_block: true
when:
- ('k3s' + '.service') in ansible_facts.services
- ansible_facts.services['k3s' + '.service'].status != 'not-found'