Example #1
0
def _update_config(line):
    '''
    Update the ServerDensity agent and restart it.

    :param str line: the extra data for sd-agent
    '''
    append('/etc/sd-agent/config.cfg', line, use_sudo=True)
    restart('sd-agent')
Example #2
0
def install_rabbitmq_plugins():
    plugin_dir = '/usr/lib/rabbitmq/lib/rabbitmq_server-2.6.1/plugins'
    plugin_files = (
        'http://www.rabbitmq.com/releases/plugins/v2.6.1/mochiweb-1.3-rmq2.6.1-git9a53dbd.ez',
        'http://www.rabbitmq.com/releases/plugins/v2.6.1/webmachine-1.7.0-rmq2.6.1-hg0c4b60a.ez',
        'http://www.rabbitmq.com/releases/plugins/v2.6.1/amqp_client-2.6.1.ez',
        'http://www.rabbitmq.com/releases/plugins/v2.6.1/rabbitmq_mochiweb-2.6.1.ez',
        'http://www.rabbitmq.com/releases/plugins/v2.6.1/rabbitmq_management-2.6.1.ez',
        'http://www.rabbitmq.com/releases/plugins/v2.6.1/rabbitmq_management_agent-2.6.1.ez',
    )
    for file in plugin_files:
        sudo('wget %s -P %s' % (file, plugin_dir,))
    # restart rabbitmq to load plugin
    restart('rabbitmq-server')
Example #3
0
def install_nginx(version=None, remove_default=True):
    '''
    Install nginx as a webserver or reverse proxy

    :param str version: the version of nginx you want to have installed if it's
        a different version than the repository version. E.g. 1.0.4
    '''
    # install from the repository to get stable version and initial config
    install('nginx')
    default_site = '/etc/nginx/sites-enabled/default'
    if remove_default and exists(default_site):
        sudo('rm %s' % default_site)
        restart('nginx')
    # if a version is specified, install that and overwrite the repo version
    if version:
        stop('nginx')
        run('mkdir -p src')
        with cd('src'):
            run('wget http://nginx.org/download/nginx-%s.tar.gz' % version)
            run('tar xf nginx-%s.tar.gz' % version)
            # requirements for nginx
            install('build-essential', 'libc6', 'libpcre3', 'libpcre3-dev',
                    'libpcrecpp0', 'libssl0.9.8', 'libssl-dev', 'zlib1g',
                    'zlib1g-dev', 'lsb-base')
            with cd('nginx-%s' % version):
                run('''./configure --with-http_ssl_module \\
                       --with-sha1=/usr/lib \\
                       --with-http_gzip_static_module \\
                       --with-http_stub_status_module \\
                       --without-http_fastcgi_module \\
                       --sbin-path=/usr/sbin \\
                       --conf-path=/etc/nginx/nginx.conf \\
                       --prefix=/etc/nginx \\
                       --error-log-path=/var/log/nginx/error.log \\
                       ''')
                run('make')
                sudo('make install')
        start('nginx')
Example #4
0
def install_apache2(type='python'):
    '''
    Install Apache2 as a application backend

    :param str type: set a type to install some extra apache modules. E.g.
        ``python``, ``php5``, ``ruby``
    '''
    install('apache2', 'libapache2-mod-rpaf')
    if type == 'python':
        install('libapache2-mod-wsgi')
    elif type == 'php5':
        install('libapache2-mod-php5', 'php5', 'php5-mysql', 'php5-gd')
    elif type == 'ruby':
        install_ruby()
        install('apache2-dev')
        sudo('gem install passenger')
        sudo('passenger-install-apache2-module')
        sudo('a2enmod passenger')
    # enable some extra modules
    sudo('a2enmod expires')
    # we want rid of the default apache config
    sudo('a2dissite default')
    restart('apache2')