-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PATH being overwritten #6785
Comments
MrTravisB: where are you setting your PATH info for the salt-minion service? Salt devs: Because the init functions for CentOS are sourced after the /etc/default/salt-xxx configs, if the user is trying to set PATH in e.g. /etc/default/salt-minion, it will be overwritten when /etc/rc.d/init.d/functions is sourced in https://github.com/saltstack/salt/blob/develop/pkg/rpm/salt-minion#L46. The system init functions (and lsb-func and lsb-vars for deb based) in all of the init scripts should probably be sourced first, then any hard-coded defaults in the init script, then the /etc/default/salt-xxx files. |
I'm not explicitly setting PATH at all for the minion. I would have hoped it would use the default PATH. |
It doesn't seem this is actually a bug with Salt. To fix it, I simply added my PATH setting to /etc/rc.d/init.d/functions and it is working fine now. I'm going to close this issue. If anyone can think of a better way around this then feel free to reopen. |
To clarify: are you wanting salt-minion's process itself to have a different PATH, or are you wanting the path for the cmd.run module/function to behave as if it were an interactive shell like you have when SSHed into the minion? The salt-minion process does actually have the default PATH for an init script on RedHat/CentOS, "/sbin:/usr/sbin:/bin:/usr/bin". You can see this set in the /etc/rc.d/init.d/functions file, which the salt-minion script sources on startup. In order to change the PATH for the salt-minion process itself, you should be able to set it in /etc/default/salt-minion, but there is currently a bug as I mentioned in my first comment about the order of sourcing being wrong. Until that is fixed, you have to set the PATH in /etc/init.d/salt-minion on RedHat/CentOS. I would advise against editing the PATH in the init.d/functions file, as your changes will be lost any time the package that provides those function is updated by RedHat/CentOS. If you want the cmd.run environment to be more like your interactive (assuming bash) shell, you need to do some things first:
Looking at the salt code, when you add the 'runas' option, the shell is invoked through either 'sudo' or 'su' depending on the OS of the minion, and all of them have the 'interactive' option passed to su/sudo. So you could just use the 'runas' option to get bash to launch an interactive shell which will then read your profile/bashrc scripts: root@salt-master:~# salt 'vbox*' cmd.run 'echo $PATH' shell='/bin/sh' runas='root'
vbox.dubkat.com:
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
root@salt-master:~# salt 'vbox*' cmd.run 'echo $PATH' shell='/bin/bash' runas='root'
vbox.dubkat.com:
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin This is simply due to the quirks of bash, so it's not really a bug in salt's cmd.run module. In any case, the init script sourcing order bug is still valid, so please feel free to reopen this issue. Otherwise I will file a separate bug. Hope this helps. |
This is how we solve the problem: instead of using service salt-minion restart |
good, I want to know is fix ? |
Running CentOS. Salt 0.16.3. Minion and master running as root user.
On minion:
On master:
The only place in saltstack codebase I can find
/sbin:/usr/sbin:/bin:/usr/bin
is in the Debian init file. I don't see it in any RHEL related files.The text was updated successfully, but these errors were encountered: