Set bash environment variables so rundeck user can execute Python virtualenvwrapper under command

1,611 views
Skip to first unread message

Hank Huang

unread,
Jan 9, 2017, 10:48:45 AM1/9/17
to rundeck-discuss
I wanted to be able to run Python virtualenv commands directly in "command" under workflow steps. I realize I needed a way to set environment variables for the rundeck user so commands like "workon" can be preloaded. I read it in the documentation somewhere that to set environment variables, you can do it in /etc/rundeck/profile , so I added the following 2 lines to the end of that file:

export WORKON_HOME=/var/lib/rundeck/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh


Some how the second line does not have effect and I couldn't figure out why. If the second line have worked, I will be able to execute the command "workon" but the log output tells me that the command is not found:

00:08:36 4. see if workon is available/bin/sh: workon: command not found
00:08:37Result: 127
00:08:37Failed: NonZeroResultCode: Result code was 127
00:08:37Execution failed: 52 in project digitalocean_management: [Workflow result: , step failures: {4=Dispatch failed on 1 nodes: [localhost: NonZeroResultCode: Result code was 127]}, Node failures: {localhost=[NonZeroResultCode: Result code was 127]}, status: failed]


But if I manually source the virtualenvwrapper.sh in the command step, it will work. But I want to look for a way to source the bash function ahead of time so I don't have to do the extra step over and over in my "command" steps like following.



If /etc/rundeck/profile is not the right way to do it, how should I have this done?

Thanks

Alex Honor

unread,
Jan 9, 2017, 11:35:55 AM1/9/17
to rundeck...@googlegroups.com
Hi Hank,

The source and execution have to be inside the same command step. Each command step occurs in a separate ssh execution so context is not persistent.

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-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/27eab7cd-95d5-4195-a348-a61f96dc1d17%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!

Reply all
Reply to author
Forward
0 new messages