The HA scenario requires failing over a (virtual) IP-address and sending gratuitous arp requests to ensure that the LAN learns that an IP failover has occurred.
Making changes to a systems IP stack and sending gratuitous arp requests requires privileged / root level access.
When the tooling making those changes already runs as root, there is of-course already sufficient privileged access.
When the tooling does not run as root then a method of granting that privileged access is necessary. A sudoers policy is one method that can grant fine-grained privileges.
Edit: The answer from @symcbean made me realise:
because many examples only grant unrestricted and unlimited privileges
you may not be aware that sudo
is explicitly designed to grant
restricted privileges. The following example grants the user george
only the rights to run those three commands (with arguments) via
sudo
with root rights
# in /etc/sudoers or as a drop-in file /etc/sudoers.d/file-name
# List of privileged commands
Cmnd_Alias IPFAILOVER = /usr/sbin/ip, /usr/sbin/arp, /usr/sbin/arping
# allow george to run the above commands as root without having to authenticate with a password
george ALL=(root) NOPASSWD: IPFAILOVER
An alternative is for example set set-uid root permissions on those commands, but that allows any and all users to send gratuitous arp requests and modify the ARP caches of neighbouring systems and/or modify the systems IP stack. That is probably less desirable.