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

22 lines
669 B
YAML

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