clustershell
clustershell copied to clipboard
Propagate environment variable on task
It will be very interesting to set environment variables which could be set by task or worker.
# Set environment variable
vars = { 'PATH': "...", 'LD_LIBRARY_PATH': "..." }
task.putenv(vars)
# or
worker.putenv(vars)
[st-cea] Let's see if it's better to add a putenv() method or to allow modifying a task.environ or worker.environ dictionary like os.environ in Python: http://docs.python.org/library/os.html?#os.environ
Scheduled for 1.2 or 1.3
[st-cea] 2 environments could be handled by the library: local environ and distant environ (depend on the worker type). Scheduled for 1.3.
[st-cea] Prioritizing. :)
[st-cea] Also, we could set special environ variables defined by the ClusterShell library, so remote processes could guess they are launched by ClusterShell. Those variables should be well known and documented.
[st-cea] ''bump''
Sorry to dig up an old task but wondered if anything further happened with this else where? i have a use case where a bunch of users can ssh into a shared account and run a script via clusterssh. it would be useful to pass some environment variable which represent the user on the host initiating the commands. I think this will likely require some configuration on the initiating host i.e. for the ssh transport adding SendEnv=CLUSTERSHELL_USER
in ssh_confg
but for me at least that would be an acceptable tradeoff :)
If the env is already set from the originating shell, then it's just a matter of SendEnv in the ssh client conf (can be done with -o on clush) and equvalent AcceptEnv lines in the sshd_config on the remote -- nothing for us to do here.