Passing Environment Variables to remote jobs and scripts

4,488 views
Skip to first unread message

Jonathan Dunn

unread,
May 6, 2014, 11:22:45 AM5/6/14
to rundeck...@googlegroups.com
In RDECK_BASE/etc/profile, I've added a number of custom environment variables in the form of RD_<VAR>.  Once I've bounced the RunDeck server, these RD_<VAR> variables are all available to commands, jobs, and scripts running on the local RunDeck server host.  

The problem I'm facing lies in trying to access these environment variables in remotely running jobs and scripts; they show up as undefined.  And that makes sense, sort of.  I'm executing a job and script on a remote host in a remote environment, so it stands to reason my local environment variables would be undefined there.

But what if I want and need them defined remotely?  What if I need to run a remote job and script, but I want the local values of the RD_<VAR> variables passed along to the remote job and script execution?  How do I do that?

I've tried adding both $RD_<VAR> and @RD_<VAR>@ onto the remote job option line, but they don't get interpreted.  They get passed forward literally, so the value on the remote end is "$RD_<VAR>", and not what $RD_<VAR> was set to in RDECK_BASE/etc/profile.



Alex Honor

unread,
May 7, 2014, 7:28:18 PM5/7/14
to rundeck...@googlegroups.com
Hi Jonathan,

The "local executor" automatically gets the rundeck environment variables as part of its context but remote node executors don't see them. Without adding a feature to rundeck to provide a global set of properties, one could use a step plugin that contains an explicit way to expose these variables (eg, either in the job step or in the rundeck config file). 

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.
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!

Levent Tutar

unread,
Jun 4, 2014, 4:40:45 AM6/4/14
to rundeck...@googlegroups.com
Hi Jonathan,

I also need to run scripts on remote hosts with parameters.
I use the replacement token to replace the parameters in scripts. This works in my case. Maybe you can use this solution.

See https://groups.google.com/forum/#!topic/rundeck-discuss/h76eHZwd6y4
Reply all
Reply to author
Forward
0 new messages