Using environment variable of another user

309 views
Skip to first unread message

Bronsky Proco

unread,
Sep 30, 2015, 5:43:03 AM9/30/15
to rundeck-discuss
Hi,

I was wondering how can I make Rundeck use the environment variables of the user I make him connect as. For example :

When the rundeck user connects to a remote server as an other user named "admin" for instance, it won't use the environment variable of the "admin" user but rundeck's. So how is it possible to make rundeck use any environment variables of the user it connects as ?

Thanks in advance,

bronsky

Alex Honor

unread,
Sep 30, 2015, 3:23:06 PM9/30/15
to rundeck...@googlegroups.com
Hi Bronsky,

If the remote side is using bash, be sure the environment variables are set in your .bashrc. Also, be sure Rundeck variables are passed through. See http://rundeck.org/docs/plugins-user-guide/ssh-plugins.html#passing-environment-variables-through-remote-command

Thanks


--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/14baa735-f3f2-43a4-8f0a-6e5af16be047%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[SimplifyOps, Inc | a...@simplifyops.com ]

Be sure to comment and vote on Rundeck Feature Development!

Bronsky Proco

unread,
Oct 1, 2015, 4:26:42 AM10/1/15
to rundeck-discuss
Hi Alex,

Thanks for answering me.

The environment variables are set in the .bashrc and I did put the AcceptEnv RD_* in my ssh config. It does pass rundeck variables but when I execute the job that makes rundeck print its environment variables when it is connected on the remote server,  they are not the same as the user it is connecting as.

For example, the "admin" user on the remote server has for $PATH this :

/home/admin/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

and when rundeck connects as "admin" on the remote server, its PATH is :

/usr/local/bin:/usr/bin:/bin:/usr/games

So how can I make Rundeck uses the original PATH ( the first one I put ) and other environment variables as well ?

Thanks in advance,

bronsky
Message has been deleted

Alex Honor

unread,
Oct 2, 2015, 12:38:18 PM10/2/15
to rundeck...@googlegroups.com
Hi Bronsky,

Not sure what is causing the difference. You might try replicating the remote command by doing

ssh -i /path/to/key user@host env

and see what variables are being set.


On Thu, Oct 1, 2015 at 2:27 AM, Bronsky Proco <bronsk...@gmail.com> wrote:
Hi Alex,

Thanks for answering me.

The environment variables are set in the .bashrc and I did put the AcceptEnv RD_* in my ssh config. It does pass rundeck variables but when I execute the job that makes rundeck print its environment variables when it is connected on the remote server,  they are not the same as the user it is connecting as.

For example, the "admin" user on the remote server has for $PATH this :

/home/admin/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

and when rundeck connects as "admin" on the remote server, its PATH is :

/usr/local/bin:/usr/bin:/bin:/usr/games

So how can I make Rundeck uses the original PATH ( the first one I put ) and other environment variables as well ?

Thanks in advance,

bronsky

Le mercredi 30 septembre 2015 11:43:03 UTC+2, Bronsky Proco a écrit :

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Bronsky Proco

unread,
Oct 5, 2015, 9:53:26 AM10/5/15
to rundeck-discuss
Hi Alex,

When I perform the command you asked me to, it prints the wrong environment variables (the ones Rundeck uses) and therefore the wrong $PATH.

Is there something I'm missing here like in Rundeck configuration ?

Alex Honor

unread,
Oct 5, 2015, 11:26:33 AM10/5/15
to rundeck...@googlegroups.com
Hi Bronsky,

This does not appear to be rundeck related but the difference in initialization between interactive and non interactive shells. Can you check how the "dot" files are being read (ie, how they are sourced)? 

Thanks





For more options, visit https://groups.google.com/d/optout.

Bronsky Proco

unread,
Oct 6, 2015, 4:42:58 AM10/6/15
to rundeck-discuss
Hi Alex,

I've just spent the last few hours to find the solution and finally found it. In the .bashrc the first condition is to do nothing if not running interactively. Since I put my environment variables after this condition, it couldn't work so I put them before and now it works !!

Anyway, thanks for spending time to answer my problem. Keep ut the good work !

bronsky
Reply all
Reply to author
Forward
0 new messages