--- # Disable k3s-agent on pi.prole.org and remove it from the cluster. # Safe to run against a live cluster — only touches pi.prole.org. # Storage (iSCSI) and pihole configuration are intentionally preserved. # # Usage: # ansible-playbook -i inventory/hosts.ini playbooks/disable_pi_k3s.yml # ansible-playbook -i inventory/hosts.ini playbooks/disable_pi_k3s.yml --check - name: Drain and delete pi node from k3s control-plane hosts: k3s_servers gather_facts: false become: true tasks: - name: Drain pi.prole.org (evict pods, ignore DaemonSets) ansible.builtin.command: cmd: kubectl drain pi.prole.org --ignore-daemonsets --delete-emptydir-data --force --timeout=120s environment: KUBECONFIG: /etc/rancher/k3s/k3s.yaml register: _drain changed_when: _drain.rc == 0 failed_when: false - name: Delete pi node from cluster ansible.builtin.command: cmd: kubectl delete node pi.prole.org --ignore-not-found environment: KUBECONFIG: /etc/rancher/k3s/k3s.yaml register: _delete_node changed_when: "'deleted' in _delete_node.stdout" failed_when: false - name: Stop and disable k3s-agent on pi.prole.org hosts: pi.prole.org gather_facts: false become: true tasks: - name: Gather minimal facts ansible.builtin.setup: gather_subset: - min - name: Check for k3s-agent systemd unit ansible.builtin.stat: path: /etc/systemd/system/k3s-agent.service register: _agent_unit - name: Stop k3s-agent service ansible.builtin.systemd: name: k3s-agent state: stopped enabled: false when: - _agent_unit.stat.exists | default(false) - not ansible_check_mode - name: Check for generic k3s systemd unit (agent variant) ansible.builtin.stat: path: /etc/systemd/system/k3s.service register: _k3s_unit - name: Stop k3s service if present (some installs use k3s not k3s-agent) ansible.builtin.systemd: name: k3s state: stopped enabled: false when: - _k3s_unit.stat.exists | default(false) - not ansible_check_mode failed_when: false - name: Confirm k3s processes are not running ansible.builtin.command: pgrep -c k3s register: _k3s_procs changed_when: false failed_when: false - name: Report k3s process status ansible.builtin.debug: msg: >- k3s processes on pi.prole.org: {{ 'NONE (clean)' if _k3s_procs.rc != 0 else _k3s_procs.stdout + ' process(es) still running' }}