0

I have recently started looking into Salt Stack and have installed a master Salt agent on an ubuntu VM.

To sun my commands when I am logged in I need to always use

sudo salt ....

Is there a way to enable the Salt to be ran with sudo by default? Meaning I don't need to type in the sudo password or use sudo at all.

I am new to linux so I apologise if this seems like a sily question. Thanks in advance

1 Answers1

2

You can create shell functions or wrapper scripts that run sudo for you. E.g. put a script like this in your $PATH (perhaps in $HOME/bin):

#!/bin/sh
sudo /path/to/tools/salt "$@"

You may want to put the actual binaries somewhere outside the user's PATH, so they don't get called directly by accident. Then just make the necessary sudo configurations to allow the user to run /path/to/real/salt instead.

If you like, you could make a more generic wrapper too, e.g.

#!/bin/sh
sudo "/path/to/tools/${0##*/}" "$@"

It takes the name of program to call from the name it was itself called as, so if called as pepper or /usr/local/bin/pepper it would run sudo pepper, and so on. Then you can symlink the various names to that same script.

To configure salt to run without a password, you can follow the instructions given here: How to run a specific program as root without a password prompt?.

ilkkachu
  • 138,973