# Sudo rules for user hybadmin

# Only commands under this path can be executed by user, hybadmin
Defaults    secure_path = /usr/sbin:/usr/bin:/usr/local/bin

hybadmin ALL=(ALL) ALL
# Hybadmin sudo permissions for appctl operations
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl start rke2-server.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop rke2-server.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart rke2-server.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl status rke2-server.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl enable rke2-server.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl disable rke2-server.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/rancher/*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/cat /etc/rancher/*

hybadmin ALL=(ALL) NOPASSWD: /usr/bin/tee /etc/rancher/rke2/*
hybadmin ALL=(ALL) NOPASSWD: /var/lib/rancher/rke2/bin/etcdctl *
hybadmin ALL=(ALL) NOPASSWD: /usr/sbin/reboot
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/pkill -9 -f rke2|kubelet|containerd-shim|etcd|k3s
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/umount -l /run/k3s/*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/umount -l /run/k3s/*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/rm -rf /var/lib/rancher/rke2/*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/rm -rf /run/k3s/*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/rm -rf /run/k3s
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/rke2 certificate rotate
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/hostnamectl
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/umount -l /run/k3s*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/umount -l /var/lib/kubelet*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/rm -rf /var/lib/rancher/rke2*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/rm -rf /run/k3s*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/hybapp-switch-repo
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/dnf upgrade -y

hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl start --no-block rke2-server.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl start rke2-agent.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl start --no-block rke2-agent.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop rke2-agent.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl enable rke2-agent.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl disable rke2-agent.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/sed -i 1i\ * /etc/chrony.conf
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/tee /etc/chrony.conf
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart chronyd
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/systemctl daemon-reload
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/rke2 server --cluster-reset
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/tee /usr/local/lib/systemd/system/rke2-agent.service
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/umount -l /var/lib/rancher*

# revisit this-
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/chmod * /etc/rancher/rke2/*
hybadmin ALL=(ALL) NOPASSWD: /usr/bin/mkdir -p /etc/rancher/rke2
