Example #1
0
def hosts_conf():
    notify('Writing hostname and hosts files.')
    cuisine.mode_sudo()
    sudo('echo "{NAME}" > /etc/hostname'.format(NAME=MACHINE['KEY']))
    sudo('hostname -F /etc/hostname')
    hosts = cuisine.text_template(templates.hosts, MACHINE)
    cuisine.file_append('/etc/hosts', hosts)
Example #2
0
def hosts_conf():
    notify('Writing hostname and hosts files.')
    cuisine.mode_sudo()
    sudo('echo "{NAME}" > /etc/hostname'.format(NAME=MACHINE['KEY']))
    sudo('hostname -F /etc/hostname')
    hosts = cuisine.text_template(templates.hosts, MACHINE)
    cuisine.file_append('/etc/hosts', hosts)
Example #3
0
def locale_conf():
    notify('Configuring locale defaults.')
    sudo('locale-gen --purge en_US.UTF-8')
    sudo(
        'echo -e "LANG=\'en_US.UTF-8\'\nLANGUAGE=\'en_US:en\'\n" > /etc/default/locale'
    )
    sudo('dpkg-reconfigure -f noninteractive locales')
Example #4
0
def ensure_production_settings():
    notify('Configuring production settings.')
    context = SENSITIVE
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.production_settings, context)
    cuisine.file_write(PROJECT['ROOT'] + '/moment/conf/production.py', content)
    restart()
Example #5
0
def ensure_production_settings():
    notify("Configuring production settings.")
    context = SENSITIVE
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.production_settings, context)
    cuisine.file_write(PROJECT["ROOT"] + "/moment/conf/production.py", content)
    restart()
Example #6
0
def link_conf():
    notify('Configuring necessary symlinks for our libraries.')
    cuisine.mode_sudo()
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libjpeg.so', '/usr/lib/libjpeg.so', symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libpng.so', '/usr/lib/libpng.so', symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libz.so', '/usr/lib/libz.so', symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libfreetype.so', '/usr/lib/libfreetype.so', symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/liblcms.so', '/usr/lib/liblcms.so', symbolic=True)
Example #7
0
def bootstrap():
    notify("Now starting the project bootstrap sequence")
    make_environment()
    clone()
    ensure_dependencies()
    ensure_production_settings()
    ensure_nginx()
    ensure_gunicorn()
    ensure_rq()
Example #8
0
def upgrade():
    notify("Now starting the project upgrade sequence")
    fetch()
    merge()
    ensure_dependencies()
    ensure_production_settings()
    ensure_nginx()
    ensure_gunicorn()
    ensure_rq()
Example #9
0
def upgrade():
    notify('Now starting the project upgrade sequence')
    fetch()
    merge()
    ensure_dependencies()
    ensure_production_settings()
    ensure_nginx()
    ensure_gunicorn()
    ensure_rq()
Example #10
0
def bootstrap():
    notify('Now starting the project bootstrap sequence')
    make_environment()
    clone()
    ensure_dependencies()
    ensure_production_settings()
    ensure_nginx()
    ensure_gunicorn()
    ensure_rq()
Example #11
0
def dir_conf():
    notify('Creating the working directory structure.')
    cuisine.mode_sudo()
    cuisine.dir_ensure(MACHINE['DIR_WORKSPACE'])
    cuisine.dir_ensure(MACHINE['DIR_ENVIRONMENTS'], recursive=True, mode=MACHINE['DIR_MODE'],
               owner=KEY, group=MACHINE['OWNER_GROUP'])
    cuisine.dir_ensure(MACHINE['DIR_PROJECTS'], recursive=True, mode=MACHINE['DIR_MODE'],
               owner=KEY, group=MACHINE['OWNER_GROUP'])
    cuisine.dir_ensure(MACHINE['DIR_SSL'], recursive=True, mode=MACHINE['DIR_MODE'],
               owner=KEY, group=MACHINE['OWNER_GROUP'])
    cuisine.dir_ensure(MACHINE['DIR_LOGS'], recursive=True, mode=MACHINE['DIR_MODE'],
               owner=KEY, group=MACHINE['OWNER_GROUP'])
Example #12
0
    def alert(self, item, message):
        try:
            for number in self.imessage_numbers:
                notify(number, item, message)

        except Exception as e:
            pprint(item, e, "FAIL")

        self.notifications += 1

        if self.notifications >= self.options["max_notifications"]:
            self.stop()
Example #13
0
def ensure_rq():
    notify("Configuring RQ.")
    context = {
        "ACTION_DATE": MACHINE["ACTION_DATE"],
        "NAME": PROJECT["NAME"],
        "KEY": KEY,
        "PROJECT_ROOT": PROJECT["ROOT"],
        "PROJECT_ENV": PROJECT["ENV"],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.rq_supervisor, context)
    cuisine.file_write("/etc/supervisor/conf.d/" + KEY + "-rq.conf", content)
    restart()
Example #14
0
def ensure_rq():
    notify('Configuring RQ.')
    context = {
        'ACTION_DATE': MACHINE['ACTION_DATE'],
        'NAME': PROJECT['NAME'],
        'KEY': KEY,
        'PROJECT_ROOT': PROJECT['ROOT'],
        'PROJECT_ENV': PROJECT['ENV'],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.rq_supervisor, context)
    cuisine.file_write('/etc/supervisor/conf.d/' + KEY + '-rq.conf', content)
    restart()
Example #15
0
def bootstrap():
    notify('Configuring the server.')
    tz_conf()
    locale_conf()
    apt_update()
    apt_upgrade()
    hosts_conf()
    dir_conf()
    apt_packages()
    custom_packages()
    pip_packages()
    profile_conf()
    firewall_conf()
    link_conf()
    reboot()
Example #16
0
def bootstrap():
    notify('Configuring the server.')
    tz_conf()
    locale_conf()
    apt_update()
    apt_upgrade()
    hosts_conf()
    dir_conf()
    apt_packages()
    custom_packages()
    pip_packages()
    profile_conf()
    firewall_conf()
    link_conf()
    reboot()
Example #17
0
def link_conf():
    notify('Configuring necessary symlinks for our libraries.')
    cuisine.mode_sudo()
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libjpeg.so',
                      '/usr/lib/libjpeg.so',
                      symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libpng.so',
                      '/usr/lib/libpng.so',
                      symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libz.so',
                      '/usr/lib/libz.so',
                      symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/libfreetype.so',
                      '/usr/lib/libfreetype.so',
                      symbolic=True)
    cuisine.file_link('/usr/lib/x86_64-linux-gnu/liblcms.so',
                      '/usr/lib/liblcms.so',
                      symbolic=True)
Example #18
0
def ensure_nginx():
    notify("Configuring nginx.")
    context = {
        "ACTION_DATE": MACHINE["ACTION_DATE"],
        "NAME": PROJECT["NAME"],
        "KEY": KEY,
        "APP_LOCATION": PROJECT["APP_LOCATION"],
        "APP_PORT": PROJECT["APP_PORT"],
        "LOCATION": MACHINE["LOCATION"],
        "PORT": MACHINE["PORT"],
        "PROJECT_ROOT": PROJECT["ROOT"],
        "ACCESS_LOG": PROJECT["LOGS"]["NGINX_ACCESS"],
        "ERROR_LOG": PROJECT["LOGS"]["NGINX_ERROR"],
        "SERVER_NAMES": " ".join(PROJECT["DOMAINS"]),
    }
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.nginx, context)
    cuisine.file_write("/etc/nginx/sites-enabled/" + KEY, content)
    sudo("/etc/init.d/nginx restart")
Example #19
0
def ensure_nginx():
    notify('Configuring nginx.')
    context = {
        'ACTION_DATE': MACHINE['ACTION_DATE'],
        'NAME': PROJECT['NAME'],
        'KEY': KEY,
        'APP_LOCATION': PROJECT['APP_LOCATION'],
        'APP_PORT': PROJECT['APP_PORT'],
        'LOCATION': MACHINE['LOCATION'],
        'PORT': MACHINE['PORT'],
        'PROJECT_ROOT': PROJECT['ROOT'],
        'ACCESS_LOG': PROJECT['LOGS']['NGINX_ACCESS'],
        'ERROR_LOG': PROJECT['LOGS']['NGINX_ERROR'],
        'SERVER_NAMES': ' '.join(PROJECT['DOMAINS'])
    }
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.nginx, context)
    cuisine.file_write('/etc/nginx/sites-enabled/' + KEY, content)
    sudo('/etc/init.d/nginx restart')
Example #20
0
def custom_packages():
    notify('Installing custom packages.')

    notify('Installing PhantomJS')
    cuisine.mode_sudo()
    cuisine.dir_ensure(MACHINE['DIR_USER_HOME'])
    with cd(MACHINE['DIR_USER_HOME']):
        sudo(
            'wget -N https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 -O phantomjs.tar.bz2'
        )
        sudo('tar jxvf phantomjs.tar.bz2')
        sudo('mv phantomjs-1.9.1-linux-x86_64 /etc/phantomjs')
        cuisine.file_link('/etc/phantomjs/bin/phantomjs',
                          '/usr/bin/phantomjs',
                          symbolic=True)

    notify('Installing CasperJS')
    cuisine.mode_sudo()
    cuisine.dir_ensure(MACHINE['DIR_USER_HOME'])
    with cd(MACHINE['DIR_USER_HOME']):
        sudo(
            'wget -N https://codeload.github.com/n1k0/casperjs/legacy.tar.gz/1.0.3  -O casperjs.tar.bz2'
        )
        sudo('tar xzvf casperjs.tar.bz2')
        sudo('mv n1k0-casperjs-76fc831 /etc/casperjs')
        cuisine.file_link('/etc/casperjs/bin/casperjs',
                          '/usr/bin/casperjs',
                          symbolic=True)
Example #21
0
def ensure_gunicorn():
    notify("Configuring gunicorn.")
    context = {
        "ACTION_DATE": MACHINE["ACTION_DATE"],
        "NAME": PROJECT["NAME"],
        "KEY": KEY,
        "APP_LOCATION": PROJECT["APP_LOCATION"],
        "APP_PORT": PROJECT["APP_PORT"],
        "APP_TIMEOUT": PROJECT["APP_TIMEOUT"],
        "APP_WSGI": PROJECT["APP_WSGI"],
        "APP_WORKERS": PROJECT["APP_WORKERS"],
        "LOCATION": MACHINE["LOCATION"],
        "PORT": MACHINE["PORT"],
        "PROJECT_ROOT": PROJECT["ROOT"],
        "PROJECT_ENV": PROJECT["ENV"],
        "ACCESS_LOG": PROJECT["LOGS"]["GUNICORN_ACCESS"],
        "ERROR_LOG": PROJECT["LOGS"]["GUNICORN_ERROR"],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.gunicorn_supervisor, context)
    cuisine.file_write("/etc/supervisor/conf.d/" + KEY + "-gunicorn.conf", content)
    restart()
Example #22
0
def dir_conf():
    notify('Creating the working directory structure.')
    cuisine.mode_sudo()
    cuisine.dir_ensure(MACHINE['DIR_WORKSPACE'])
    cuisine.dir_ensure(MACHINE['DIR_ENVIRONMENTS'],
                       recursive=True,
                       mode=MACHINE['DIR_MODE'],
                       owner=KEY,
                       group=MACHINE['OWNER_GROUP'])
    cuisine.dir_ensure(MACHINE['DIR_PROJECTS'],
                       recursive=True,
                       mode=MACHINE['DIR_MODE'],
                       owner=KEY,
                       group=MACHINE['OWNER_GROUP'])
    cuisine.dir_ensure(MACHINE['DIR_SSL'],
                       recursive=True,
                       mode=MACHINE['DIR_MODE'],
                       owner=KEY,
                       group=MACHINE['OWNER_GROUP'])
    cuisine.dir_ensure(MACHINE['DIR_LOGS'],
                       recursive=True,
                       mode=MACHINE['DIR_MODE'],
                       owner=KEY,
                       group=MACHINE['OWNER_GROUP'])
Example #23
0
def apt_packages(databases=MACHINE['DATABASES']):
    notify('Installing all required system packages.')
    cuisine.package_ensure('ufw')
    cuisine.package_ensure('supervisor')
    cuisine.package_ensure('python-dev')
    cuisine.package_ensure('python-setuptools')
    cuisine.package_ensure('python-software-properties')
    cuisine.package_ensure('g++')
    cuisine.package_ensure('make')
    cuisine.package_ensure('cmake')
    cuisine.package_ensure('build-essential')
    cuisine.package_ensure('checkinstall')
    cuisine.package_ensure('imagemagick')
    cuisine.package_ensure('graphicsmagick-imagemagick-compat')
    cuisine.package_ensure('libxml2-dev')
    cuisine.package_ensure('libjpeg8-dev')
    cuisine.package_ensure('libpng-dev')
    cuisine.package_ensure('zlib1g-dev')
    cuisine.package_ensure('libfreetype6-dev')
    cuisine.package_ensure('liblcms1-dev')
    cuisine.package_ensure('python')
    cuisine.package_ensure('python-pip')
    cuisine.package_ensure('nginx')
    cuisine.package_ensure('git-core')
    cuisine.package_ensure('mercurial')

    if databases:
        if 'postgres' in databases:
            cuisine.package_ensure('postgresql')
            cuisine.package_ensure('postgresql-contrib')
            cuisine.package_ensure('postgresql-server-dev-all')
            # Not working, do manually
            #postgres_conf()

        if 'redis' in databases:
            cuisine.package_ensure('redis-server')
Example #24
0
def apt_packages(databases=MACHINE['DATABASES']):
    notify('Installing all required system packages.')
    cuisine.package_ensure('ufw')
    cuisine.package_ensure('supervisor')
    cuisine.package_ensure('python-dev')
    cuisine.package_ensure('python-setuptools')
    cuisine.package_ensure('python-software-properties')
    cuisine.package_ensure('g++')
    cuisine.package_ensure('make')
    cuisine.package_ensure('cmake')
    cuisine.package_ensure('build-essential')
    cuisine.package_ensure('checkinstall')
    cuisine.package_ensure('imagemagick')
    cuisine.package_ensure('graphicsmagick-imagemagick-compat')
    cuisine.package_ensure('libxml2-dev')
    cuisine.package_ensure('libjpeg8-dev')
    cuisine.package_ensure('libpng-dev')
    cuisine.package_ensure('zlib1g-dev')
    cuisine.package_ensure('libfreetype6-dev')
    cuisine.package_ensure('liblcms1-dev')
    cuisine.package_ensure('python')
    cuisine.package_ensure('python-pip')
    cuisine.package_ensure('nginx')
    cuisine.package_ensure('git-core')
    cuisine.package_ensure('mercurial')

    if databases:
        if 'postgres' in databases:
            cuisine.package_ensure('postgresql')
            cuisine.package_ensure('postgresql-contrib')
            cuisine.package_ensure('postgresql-server-dev-all')
            # Not working, do manually
            #postgres_conf()

        if 'redis' in databases:
            cuisine.package_ensure('redis-server')
Example #25
0
def ensure_gunicorn():
    notify('Configuring gunicorn.')
    context = {
        'ACTION_DATE': MACHINE['ACTION_DATE'],
        'NAME': PROJECT['NAME'],
        'KEY': KEY,
        'APP_LOCATION': PROJECT['APP_LOCATION'],
        'APP_PORT': PROJECT['APP_PORT'],
        'APP_TIMEOUT': PROJECT['APP_TIMEOUT'],
        'APP_WSGI': PROJECT['APP_WSGI'],
        'APP_WORKERS': PROJECT['APP_WORKERS'],
        'LOCATION': MACHINE['LOCATION'],
        'PORT': MACHINE['PORT'],
        'PROJECT_ROOT': PROJECT['ROOT'],
        'PROJECT_ENV': PROJECT['ENV'],
        'ACCESS_LOG': PROJECT['LOGS']['GUNICORN_ACCESS'],
        'ERROR_LOG': PROJECT['LOGS']['GUNICORN_ERROR'],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.gunicorn_supervisor, context)
    cuisine.file_write('/etc/supervisor/conf.d/' + KEY + '-gunicorn.conf',
                       content)
    restart()
Example #26
0
def custom_packages():
    notify('Installing custom packages.')

    notify('Installing PhantomJS')
    cuisine.mode_sudo()
    cuisine.dir_ensure(MACHINE['DIR_USER_HOME'])
    with cd(MACHINE['DIR_USER_HOME']):
        sudo('wget -N https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2 -O phantomjs.tar.bz2')
        sudo('tar jxvf phantomjs.tar.bz2')
        sudo('mv phantomjs-1.9.1-linux-x86_64 /etc/phantomjs')
        cuisine.file_link('/etc/phantomjs/bin/phantomjs',
                          '/usr/bin/phantomjs', symbolic=True)

    notify('Installing CasperJS')
    cuisine.mode_sudo()
    cuisine.dir_ensure(MACHINE['DIR_USER_HOME'])
    with cd(MACHINE['DIR_USER_HOME']):
        sudo('wget -N https://codeload.github.com/n1k0/casperjs/legacy.tar.gz/1.0.3  -O casperjs.tar.bz2')
        sudo('tar xzvf casperjs.tar.bz2')
        sudo('mv n1k0-casperjs-76fc831 /etc/casperjs')
        cuisine.file_link('/etc/casperjs/bin/casperjs',
                          '/usr/bin/casperjs', symbolic=True)
Example #27
0
def configure_user():
    notify('Configuring user.')
    sudo('adduser moment', user='******')
    sudo('usermod -a -G sudo moment', user='******')
Example #28
0
def pip_packages():
    notify('Installing required system python packages.')
    cuisine.mode_sudo()
    cuisine.python_package_ensure('virtualenv')
    cuisine.python_package_ensure('virtualenvwrapper')
Example #29
0
def locale_conf():
    notify('Configuring locale defaults.')
    sudo('locale-gen --purge en_US.UTF-8')
    sudo('echo -e "LANG=\'en_US.UTF-8\'\nLANGUAGE=\'en_US:en\'\n" > /etc/default/locale')
    sudo('dpkg-reconfigure -f noninteractive locales')
Example #30
0
def pip_packages():
    notify('Installing required system python packages.')
    cuisine.mode_sudo()
    cuisine.python_package_ensure('virtualenv')
    cuisine.python_package_ensure('virtualenvwrapper')
Example #31
0
def flushall():
    notify('Flushing ALL Redis keys.')
    local('redis-cli FLUSHALL')
Example #32
0
def deploy():
    notify("Now starting the project deploy sequence")
    fetch()
    merge()
    restart()
Example #33
0
def profile_conf():
    notify('Configuring .profile settings.')
    profile = cuisine.text_template(templates.profile, MACHINE)
    cuisine.file_append(MACHINE['OWNER_PROFILE'], profile)
    run('source ' + MACHINE['OWNER_PROFILE'])
Example #34
0
def profile_conf():
    notify('Configuring .profile settings.')
    profile = cuisine.text_template(templates.profile, MACHINE)
    cuisine.file_append(MACHINE['OWNER_PROFILE'], profile)
    run('source ' + MACHINE['OWNER_PROFILE'])
Example #35
0
def tz_conf():
    notify('Configuring timezone defaults.')
    sudo('echo "Etc/UTC" > /etc/timezone')
    sudo('dpkg-reconfigure -f noninteractive tzdata')
Example #36
0
def configure_user():
    notify('Configuring user.')
    sudo('adduser moment', user='******')
    sudo('usermod -a -G sudo moment', user='******')
Example #37
0
def deploy():
    notify('Now starting the project deploy sequence')
    fetch()
    merge()
    restart()
Example #38
0
def tz_conf():
    notify('Configuring timezone defaults.')
    sudo('echo "Etc/UTC" > /etc/timezone')
    sudo('dpkg-reconfigure -f noninteractive tzdata')