beanstalk-stack / beanstalk / tasks /

import hashlib
from fabric.api import *
from ground_soil.filesystem import rsync
from beanstalk.decorators import beanstalk_role
from beanstalk.tasks.utils import load_role_settings as load_beanstalk_settings, load_web_servers
from beanstalk.console.titles import tool_title
from beanstalk.validator import validate_file_existence

def add(**settings_patches):
    """Add current user to beanstalk-stack server
    # Load settings

    print tool_title('Beanstalk-Stack users tool')
    print ''

    # Get ssh public key
    ssh_pub_key_path = prompt('Where\'s your ssh public key?', default='~/.ssh/',
    with open(ssh_pub_key_path, 'r') as f:
        key_content =
    hash_key = hashlib.md5(key_content).hexdigest()[:16]
    tmp_path = '/tmp/beanstalk-stack.{hash}.pub.key'.format(hash=hash_key)

    def add_user_core():
        host_name = env.host_string.split('@')[-1]

        local(rsync(ssh_pub_key_path, 'beanstalk@{host}:{key_path}'.format(host=host_name, key_path=tmp_path)))
        run('bsjack server.add_user:{key_path},clean_tmp_key=True'.format(key_path=tmp_path))

    with settings(hide('running')):
        # TODO: Should not prompt beanstalk's SSH password
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.