bashrc or bash_profile not being sourced

69 views
Skip to first unread message

jepper

unread,
Mar 5, 2014, 8:08:12 AM3/5/14
to ansible...@googlegroups.com
I think this has been discussed before. The documentations says:

"If you want to run a command through the shell (say you are using <, >, |, etc), you actually want the shell module instead. The command module is much more secure as it’s not affected by the user’s environment." 

Implicitly, I read this as if I do use the shell command, I should get the users environment. Is this assumption wrong?

Now I do this, occasionally, in order to include anything from my user profile:
  shell: . ~/.bashrc && env > /tmp/env

The use case I have is to install a mule license, which requires MULE_HOME. I could write a two line wrapper, but I'd rather not have more parts than I can get away with. I do as follows:
  shell: . ~/.bashrc && ./mule -installLicense {{ mule_user_home }}/mule-ee-license.lic chdir={{ mule_home }}/bin

Brian Coca

unread,
Mar 6, 2014, 11:00:07 AM3/6/14
to ansible...@googlegroups.com
a few things:

 - you have a hash in ansible_env that shows what the environment is  (for user you gathered facts as).
 - ansible doesn't source .rc files
 - the environment: keyword lets you set env variables for the execution context.

Reply all
Reply to author
Forward
0 new messages