ansible JAVA_HOME does not take effect in question

solution

~ / .bash_profile is interactive, login way into the bash running, meaning only takes effect when the user logs on.
~ / .bashrc is an interactive non-login bash way into the run, the user need not log in, as long as that user to run the command line will read the file.
The difference between the above two, ansible non-login is run, it needs to be disposed in the environment variable in ~ / .bashrc to succeed

Further reading

Address reprint: https://www.jianshu.com/p/b5c4113b28d7?utm_campaign

  • We do is login login shell, loads /etc/profile,~/.bash_profile

  • Such ansible ssh remote execution is non-login shell, not load etc / profile, ~ / .bash_profile, but loading etc / bashrc and ~ / .bashrc

About login shell and non-login shell

"Bird Brother Linux private kitchens based learning articles" in this description / etc / profile and / etc / bashrc difference:

  • login shell: the need to complete the login process when acquiring bash, called the login shell. For example, you want the tty1 ~ tty6 login, enter your user account and password, bash acquired at the time called "login shell."

  • non-login shell: bash interface methods need not be repeated to obtain signed move, for example:

(1) After you log in to Linux Xwindow, and then to start the graphical interface to the terminal X, in which case the terminal interface does not need to enter the account number and password again, the bash environment is called a non-login shell.

(2) issued in your original environment once again bash bash this command, the same did not enter the account password, and that the second bash (subroutine) is also non-login shell.

We see ~ / .bash_profile, we found that there is such a content:

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

When ~ / .bashrc exists, login shell introduce ~ / .bashrc environment variables

We look at ~ / .bashrc, we found some similar content

if [ -f /etc/bashrc ]; then

        . /etc/bashrc

fi

When the / etc / bashrc exists, login shell introduce / etc / environment variables within bashrc

Then:

  • Sequentially loading login shell environment variables are: ① / etc / profile ② ~ / .bash_profile ③ ~ / .bashrc ④ / etc / bashrc

  • Sequentially loaded non-login shell environment variables are: ① ~ / .bashrc ② / etc / bashrc

Guess you like

Origin www.cnblogs.com/Peter2014/p/11645734.html