add sudo to k3s kubectl commands in update playbook

This commit is contained in:
Astra Logical 2026-07-21 18:09:18 -04:00
parent 190f56770a
commit 4361ecc3a0

View file

@ -19,7 +19,7 @@
# For NixOS, we just run the upgrade and check if a reboot is flagged.
- name: Run NixOS update command
command: nixos-rebuild switch --upgrade
command: sudo nix flake update --flake $NIX_FLAKE_PATH && sudo nixos-rebuild switch --flake $NIX_FLAKE_PATH#$HOSTNAME
register: nixos_status
when: inventory_hostname in groups['k3s_agents_nixos']
@ -32,7 +32,7 @@
# --- THE KUBERNETES DRAIN PHASE ---
- name: Drain the node safely
command: >
k3s kubectl drain {{ inventory_hostname }}
sudo k3s kubectl drain {{ inventory_hostname }}
--ignore-daemonsets
--delete-emptydir-data
--force
@ -50,6 +50,6 @@
# --- THE UNCORDON PHASE ---
- name: Uncordon the node
command: k3s kubectl uncordon {{ inventory_hostname }}
command: sudo k3s kubectl uncordon {{ inventory_hostname }}
delegate_to: "{{ active_master }}"
when: (reboot_required.stat.exists | default(false)) or ('changed' in nixos_status | default({}))