Source

caktus-deployment / mallet / templates / packages.py

Full commit
Colin Copeland e240ff5 





























































import logging

from fabric.api import env

from mallet.bootstrap.apt import lenny
from mallet.bootstrap.base import PackageGroup
from mallet.utils import create_ssh, call, write, writelines, chown


logger = logging.getLogger('mallet.templates.node')


class SCM(PackageGroup):
    packages = ['subversion', 'git-core', 'mercurial']


class BuildEssential(PackageGroup):
    packages = ['build-essential']


class SSH(PackageGroup):
    packages = ['openssh-server']

    def post_install(self, node_wrapper):
        config = env.cfg.config
        if config.has_option('mallet', 'public_key'):
            call(['mkdir', '-p', '/root/.ssh'])
            public_key = open(config.get('mallet', 'public_key')).read()
            write('/root/.ssh/authorized_keys', public_key, append=True)


class Postgres(lenny.Postgres):
    packages = ['postgresql', 'postgresql-server-dev-8.4', 'pwgen']

    def post_install(self, node_wrapper):
        call(['locale-gen', 'en_US.UTF-8'])
        call(['update-locale', 'LANG=en_US.UTF-8'])
        call(['pg_dropcluster', '--stop', '8.4', 'main'])
        call(['pg_createcluster', '--start', '-e', 'UTF-8', '8.4', 'main'])


class Python(PackageGroup):
    packages = ['ipython', 'python-setuptools', 'python-dev', 'libpq-dev',
                'libapache2-mod-wsgi', 'python-imaging']

    def post_install(self, node_wrapper):
        call(['easy_install', '-U', 'pip'])
        call(['pip', 'install', '-U', 'virtualenv'])
        call(['pip', 'install', '-U', 'distribute'])
        call(['pip', 'install', '-U', 'distribute'])
        call(['pip', 'install', '-U', 'psycopg2'])


class Apache(lenny.Apache):

    def post_install(self, node_wrapper):
        super(Apache, self).post_install(node_wrapper)
        logger.info('Creating clients group')
        call(['addgroup', 'clients'])
        logger.info('Creating sudoers file')
        sudoers = ['%clients ALL=NOPASSWD: /etc/init.d/apache2 '
                   'reload, /etc/init.d/apache2 restart']
        writelines('/etc/sudoers', sudoers)