Example #1
0
def addWebserver(webserver):
    """
    Add a virtual webserver
    :param webserver:
    :return:
    """
    hostdir = gethostdir()

    # Stop uwsgi
    service.stop('uwsgi')

    # Create user
    homedir = '%(hostdir)s/%(webserver)s' % locals()
    require.user(webserver, home=homedir, shell='/bin/bash',)

    # Create web directory
    createDirectory(hostdir, webserver)

    CONFIG_TPL = '''
    server {
        server_name %(server_name)s %(server_alias)s;
        root        %(docroot)s/%(server_name)s/www;
        access_log  %(docroot)s/%(server_name)s/log/access.log;
    }'''

    require.nginx.site(
        webserver, template_contents=CONFIG_TPL,
        server_alias='',
        docroot=hostdir,
    )

    require.network.host('127.0.0.1', webserver)
Example #2
0
def openerp_rsyslog():
    require.files.file(
        '/etc/rsyslog.d/20-openerp.conf', 
        source='files/etc/rsyslog.d/20-openerp.conf', 
        owner='root', 
        group='root', 
        mode=644, 
        use_sudo = True
    )
    require.files.file(
        '/etc/init.d/openerp',
        source='files/etc/init.d/openerp',
        owner='root',
        group='root',
        mode='755',
        use_sudo=True
    )
    require.files.directory(
        '/var/log/openerp',
        mode=777, 
        use_sudo=True
    )
    require.service.restarted('rsyslog')
    ## we need a full stop and start as we updated /etc/init.d/openerp file
    puts('Stopping openerp')
    service.stop('openerp')
    puts('Starting openerp')
    service.start('openerp')
Example #3
0
def bootstrap_cluster():
    """Run on the first machine of a new cluster, without any mysqld daemons running."""
    puts(red('This should be run on the FIRST machine of the new cluster'))
    puts(red('No other mysqld daemons should be running for this cluster'))
    if service.is_running('mysql'):
        service.stop('mysql')
    # nohup below is very important. See:
    # http://serverfault.com/questions/709223/galera-new-cluster-wsrep-unknown-error-141
    run('nohup service mysql bootstrap')
Example #4
0
def stopped(service):
    """
    Require a service to be stopped.

    ::

        from fabtools import require

        require.service.stopped('foo')
    """
    if is_running(service):
        stop(service)
Example #5
0
def stopped(service):
    """
    Require a service to be stopped.

    ::

        from fabtools import require

        require.service.stopped('foo')
    """
    if is_running(service):
        if using_systemd():
            systemd.stop(service)
        else:
            stop(service)
Example #6
0
def remove_kraken_instance(instance, purge_logs=False, apply_on='engines'):
    """
    Remove a kraken instance entirely
      * Stop the service
      * Remove startup at boot time
      * Remove initscript
      * Remove configuration and pid directory
    apply_on values:
     - engines: apply on instance.kraken_engines
     - reverse: apply on all engines except instance.kraken_engines
     - all: apply on all engines
    """
    instance = get_real_instance(instance)
    if apply_on == 'engines':
        hosts, exclude_hosts = instance.kraken_engines, ()
    elif apply_on == 'reverse':
        hosts, exclude_hosts = env.roledefs['eng'], instance.kraken_engines
    elif apply_on == 'all':
        hosts, exclude_hosts = env.roledefs['eng'], ()
    else:
        abort("Bad 'apply_on' parameter value: {}".format(apply_on))

    for host in set(hosts) - set(exclude_hosts):
        with settings(host_string=host, warn_only=True):
            print("INFO: removing kraken instance {} from {}".format(
                instance.name, get_host_addr(host)))

            service.stop('kraken_{}'.format(instance.name))
            run("sleep 3")
            # TODO test this on systemd machines
            if env.use_systemd:
                run("systemctl disable kraken_{}.service".format(
                    instance.name))
                run('systemctl daemon-reload')
                run("rm -f {}/kraken_{}.service".format(
                    env.service_path(), instance.name))
            else:
                run("rm -f {}/kraken_{}".format(env.service_path(),
                                                instance.name))
            run("rm -rf {}/{}/".format(env.kraken_basedir, instance.name))
            if purge_logs:
                run("rm -f {}/{}.log".format(env.kraken_log_basedir,
                                             instance.name))
Example #7
0
def recreate_pvedata(dirsave, size):
    """
    Recreate the pve-data with the defined size
    """

    # Stop service
    service.stop('pvedaemon')
    service.stop('vz')
    service.stop('qemu-server')

    # Backup the /var/lib/vz
    run('tar -czf %s/vz.tgz /var/lib/vz' % dirsave)

    # Delete the pve-data
    run('umount /var/lib/vz')
    run('lvremove /dev/pve/data')

    # Create the new pve-data
    run('lvcreate -n data -L %s pve' % size)
    run('mkfs.ext3 /dev/mapper/pve-data')
    run('mount /dev/mapper/pve-data /var/lib/vz')

    # Restore the Backup /var/lib/vz
    run('tar -xzf %s/vz.tgz -C /' % dirsave)

    # Start service
    service.start('qemu-server')
    service.start('vz')
    service.start('pvedaemon')
Example #8
0
def recreate_pvedata(dirsave, size):
    """
    Recreate the pve-data with the defined size
    """

    # Stop service
    service.stop('pvedaemon')
    service.stop('vz')
    service.stop('qemu-server')

    # Backup the /var/lib/vz
    run('tar -czf %s/vz.tgz /var/lib/vz' % dirsave)

    # Delete the pve-data
    run('umount /var/lib/vz')
    run('lvremove /dev/pve/data')

    # Create the new pve-data
    run('lvcreate -n data -L %s pve' % size)
    run('mkfs.ext3 /dev/mapper/pve-data')
    run('mount /dev/mapper/pve-data /var/lib/vz')

    # Restore the Backup /var/lib/vz
    run('tar -xzf %s/vz.tgz -C /' % dirsave)

    # Start service
    service.start('qemu-server')
    service.start('vz')
    service.start('pvedaemon')
Example #9
0
def remove_kraken_instance(instance, purge_logs=False, apply_on='engines'):
    """
    Remove a kraken instance entirely
      * Stop the service
      * Remove startup at boot time
      * Remove initscript
      * Remove configuration and pid directory
    apply_on values:
     - engines: apply on instance.kraken_engines
     - reverse: apply on all engines except instance.kraken_engines
     - all: apply on all engines
    """
    instance = get_real_instance(instance)
    if apply_on == 'engines':
        hosts, exclude_hosts = instance.kraken_engines, ()
    elif apply_on == 'reverse':
        hosts, exclude_hosts = env.roledefs['eng'], instance.kraken_engines
    elif apply_on == 'all':
        hosts, exclude_hosts = env.roledefs['eng'], ()
    else:
        abort("Bad 'apply_on' parameter value: {}".format(apply_on))

    for host in set(hosts) - set(exclude_hosts):
        with settings(
            host_string=host,
            warn_only=True
        ):
            print("INFO: removing kraken instance {} from {}".format(instance.name, get_host_addr(host)))

            service.stop('kraken_{}'.format(instance.name))
            run("sleep 3")
            # TODO test this on systemd machines
            if env.use_systemd:
                run("systemctl disable kraken_{}.service".format(instance.name))
                run('systemctl daemon-reload')
            run("rm -f {}/kraken_{}".format(env.service_path(), instance.name))
            run("rm -rf {}/{}/".format(env.kraken_basedir, instance.name))
            if purge_logs:
                run("rm -f {}/{}.log".format(env.kraken_log_basedir, instance.name))
Example #10
0
def addWebserver(webserver):
    """
    Add a virtual webserver
    :param webserver:
    :return:
    """
    hostdir = gethostdir()

    # Stop uwsgi
    service.stop('uwsgi')

    # Create user
    homedir = '%(hostdir)s/%(webserver)s' % locals()
    require.user(
        webserver,
        home=homedir,
        shell='/bin/bash',
    )

    # Create web directory
    createDirectory(hostdir, webserver)

    CONFIG_TPL = '''
    server {
        server_name %(server_name)s %(server_alias)s;
        root        %(docroot)s/%(server_name)s/www;
        access_log  %(docroot)s/%(server_name)s/log/access.log;
    }'''

    require.nginx.site(
        webserver,
        template_contents=CONFIG_TPL,
        server_alias='',
        docroot=hostdir,
    )

    require.network.host('127.0.0.1', webserver)
Example #11
0
def stopped():
    """
    Ensure that the firewall is stopped.
    """
    if not is_stopped():
        stop('shorewall')
Example #12
0
def stopped():
    """
    Ensure the firewall is stopped
    """
    if not is_stopped():
        stop('shorewall')
Example #13
0
def stop_tomcat():
    """
    Stop the Tomcat service.
    """
    stop('tomcat')
Example #14
0
def stop_tomcat():
    """
    Stop the Tomcat service.
    """
    stop('tomcat')
Example #15
0
def stop():
    service.stop(service_name)
Example #16
0
def stopped():
    """
    Ensure that the firewall is stopped.
    """
    if not is_stopped():
        stop("shorewall")
Example #17
0
def stop(component):
    service.stop(component)
Example #18
0
def stop():
    """ Starts redis daemon """
    service.stop('redis_6379')