Skip to content

Instantly share code, notes, and snippets.

@jtriley
Created August 9, 2012 19:28
Show Gist options
  • Save jtriley/3307331 to your computer and use it in GitHub Desktop.
Save jtriley/3307331 to your computer and use it in GitHub Desktop.
Example StarCluster plugin that configures environment variables on all nodes
# This is an example config that assumes scenv.py is either in
# $HOME/.starcluster/plugins or lives somewhere in your $PYTHONPATH
[plugin env]
setup_class = scenv.EnvPlugin
# add as many key=value pairs as you like separated by ','
env_vars_list = 'PYTHONPATH=/path/to/python/mods, MYENV=some_value'
[cluster default]
...
plugins = env
# Install this file to $HOME/.starcluster/plugins/scenv.py or somewhere on your $PYTHONPATH
from starcluster.clustersetup import ClusterSetup
from starcluster.logger import log
class EnvPlugin(ClusterSetup):
def __init__(self, env_vars_list):
self.env_vars_list = '\n'.join([v.strip() for v in env_vars_list.split(',')])
def run(self, nodes, master, user, user_shell, volumes):
log.info("Setting environment on all nodes...")
for node in nodes:
env_file = node.ssh.remote_file('/etc/profile.d/scenv.sh', 'w')
env_file.write(self.env_vars_list)
env_file.close()
@scollis
Copy link

scollis commented Jan 22, 2016

Trying the comment and no love.. nothing written to .bashrc and no env variables added.. trying to replace base python with anaconda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment