def setup_index(): set_hostname("s0") setup_dns() setup_sql()
def setup_node(index): if not path.exists('packages/lasana_node_home.tar.gz'): raise Exception('lasana_node_home.tar.gz does not exist. Run fab create_node_home_package first.') # Install lasaña dependencies run('aptitude install -y --without-recommends python-{virtualenv,psycopg2,flup} sudo git gettext', pty=False) # Create new user create_lasana_user() # Upload home put('packages/lasana_node_home.tar.gz', '/lasana/home.tar.gz') with cd('/lasana'): # Uncompress home sudo('tar zxfvp home.tar.gz', user='******') run('rm home.tar.gz') # Create a virtualenv sudo('umask 077; virtualenv --setuptools env', user='******') # Install Django and other requirements suprun('pip install -r requirements.txt') if not exists('lasana'): # Download lasaña repo from git suprun('git clone git://github.com/ntrrgc/lasana.git -b distributed') else: # Update lasaña repo with cd('lasana'): suprun('git pull') # Git version of lasaña requires compiling some things with cd('lasana'): # Compile messages (translations) suprun('django-admin.py compilemessages') # Collect static resources suprun('python manage.py collectstatic --noinput', umask=0027) # Sync database suprun('python manage.py synchronized_syncdb') # Register node in the database, getting a node Id suprun('python manage.py registernode') # Get node name from node Id node_name = 's' + run('cat nodeid') # Set hostname to the given node name set_hostname(node_name) # get only the subdomain part # Install lasaña initscript put('packages/lasana_initscript.sh', '/etc/init.d/lasana') run('chmod +x /etc/init.d/lasana') # Set it to boot with the system run('update-rc.d lasana defaults') # Start lasaña run('/etc/init.d/lasana start', pty=False) # Install and configure the web server setup_lighttpd() # Register the new name in DNS server execute(register_node_in_dns, node_name, get_ip_address(), hosts=[index])