Nereus/scripts/provision/roles/k3s_agent/tasks/main.yml

22 lines
736 B
YAML

---
- name: Require the runtime cluster token
ansible.builtin.assert:
that: lookup('ansible.builtin.env', 'K3S_TOKEN') | length >= 32
fail_msg: "K3S_TOKEN must contain at least 32 characters."
no_log: true
- name: Install or reconcile the k3s agent
ansible.builtin.command: /var/tmp/k3s-install.sh
environment:
INSTALL_K3S_VERSION: "{{ k3s_version }}"
INSTALL_K3S_EXEC: "agent --node-ip {{ k3s_node_ip }}"
K3S_URL: "https://{{ hostvars[groups['k3s_server'][0]].k3s_node_ip }}:6443"
K3S_TOKEN: "{{ lookup('ansible.builtin.env', 'K3S_TOKEN') }}"
changed_when: false
no_log: true
- name: Enable the k3s agent
ansible.builtin.systemd_service:
name: k3s-agent
enabled: true
state: started