Exemplo n.º 1
0
def server(version=None, password=None):
    """
    Require a MySQL server to be installed and running.

    Example::

        from fabtools import require

        require.mysql.server(password='******')

    """
    if version:
        pkg_name = 'mysql-server-%s' % version
    else:
        pkg_name = 'mysql-server'

    if not is_installed(pkg_name):
        if password is None:
            password = prompt_password()

        with settings(hide('running')):
            preseed_package('mysql-server', {
                'mysql-server/root_password': ('password', password),
                'mysql-server/root_password_again': ('password', password),
            })

        package(pkg_name)

    started('mysql')
Exemplo n.º 2
0
def server(mailname):
    """
    Require a Postfix email server.

    This makes sure that Postfix is installed and started.

    ::

        from fabtools import require

        # Handle incoming email for our domain
        require.postfix.server('example.com')

    """

    # Ensure the package is installed
    if not is_installed('postfix'):
        preseed_package('postfix', {
            'postfix/main_mailer_type': ('select', 'Internet Site'),
            'postfix/mailname': ('string', mailname),
            'postfix/destinations': ('string', '%s, localhost.localdomain, localhost ' % mailname),
        })
        install('postfix')

    # Ensure the service is started
    started('postfix')
Exemplo n.º 3
0
def server(mailname):
    """
    Require a Postfix email server.

    This makes sure that Postfix is installed and started.

    ::

        from fabtools import require

        # Handle incoming email for our domain
        require.postfix.server('example.com')

    """

    # Ensure the package is installed
    if not is_installed('postfix'):
        preseed_package(
            'postfix', {
                'postfix/main_mailer_type': ('select', 'Internet Site'),
                'postfix/mailname': ('string', mailname),
                'postfix/destinations':
                ('string', '%s, localhost.localdomain, localhost ' % mailname),
            })
        install('postfix')

    # Ensure the service is started
    started('postfix')
Exemplo n.º 4
0
def server(version=None, password=None):
    """
    Require a MySQL server to be installed and running.

    Example::

        from fabtools import require

        require.mysql.server(password='******')

    """
    if version:
        pkg_name = 'mysql-server-%s' % version
    else:
        pkg_name = 'mysql-server'

    if not is_installed(pkg_name):
        if password is None:
            password = prompt('Please enter password for MySQL user "root":' %
                              user)

        with settings(hide('running')):
            preseed_package(
                'mysql-server', {
                    'mysql-server/root_password': ('password', password),
                    'mysql-server/root_password_again': ('password', password),
                })

        package(pkg_name)

    started('mysql')
Exemplo n.º 5
0
def server(version=None, password=None):
    """
    Require a MySQL server to be installed and running.

    Example::

        from fabtools import require

        require.mysql.server(password='******')

    """
    if version:
        pkg_name = "mysql-server-%s" % version
    else:
        pkg_name = "mysql-server"

    if not is_installed(pkg_name):
        if password is None:
            password = prompt_password()

        with settings(hide("running")):
            preseed_package(
                "mysql-server",
                {
                    "mysql-server/root_password": ("password", password),
                    "mysql-server/root_password_again": ("password", password),
                },
            )

        package(pkg_name)

    started("mysql")
Exemplo n.º 6
0
def server(mailname):
    """
    Require a Postfix email server
    """

    # Ensure the package is installed
    if not is_installed('postfix'):
        preseed_package('postfix', {
            'postfix/main_mailer_type': ('select', 'Internet Site'),
            'postfix/mailname': ('string', mailname),
            'postfix/destinations': ('string', '%s, localhost.localdomain, localhost ' % mailname),
        })
        install('postfix')

    # Ensure the service is started
    started('postfix')
Exemplo n.º 7
0
def server(mailname):
    """
    I can haz postfix email server
    """

    # Ensure the package is installed
    if not is_installed('postfix'):
        preseed_package('postfix', {
            'postfix/main_mailer_type': ('select', 'Internet Site'),
            'postfix/mailname': ('string', mailname),
            'postfix/destinations': ('string', '%s, localhost.localdomain, localhost ' % mailname),
        })
        install('postfix')

    # Ensure the service is started
    started('postfix')
Exemplo n.º 8
0
def server(version='5.1', password=None):
    """
    Require a MySQL server
    """
    if not is_installed("mysql-server-%s" % version):
        if password is None:
            password = prompt_password()

        with settings(hide('running')):
            preseed_package('mysql-server', {
                'mysql-server/root_password': ('password', password),
                'mysql-server/root_password_again': ('password', password),
            })

        package('mysql-server-%s' % version)

    started('mysql')
Exemplo n.º 9
0
def server(version='5.1', password=None):
    """
    Require a MySQL server
    """
    if not is_installed("mysql-server-%s" % version):
        if password is None:
            password = prompt_password()

        with settings(hide('running')):
            preseed_package(
                'mysql-server', {
                    'mysql-server/root_password': ('password', password),
                    'mysql-server/root_password_again': ('password', password),
                })

        package('mysql-server-%s' % version)

    started('mysql')
Exemplo n.º 10
0
    def install_postfix(self):
        # def install_postfix(mailname):
        """
        Require a Postfix email server.

        This makes sure that Postfix is installed and started.

        ::

            from fabtools import require

            # Handle incoming email for our domain
            require.postfix.server('example.com')

        """
        self.get_env()
        self.copy_mailgate_file()
        # Ensure the package is installed
        if not is_installed('postfix'):
            preseed_package(
                'postfix', {
                    'postfix/main_mailer_type': ('select', 'Internet Site'),
                    'postfix/mailname': ('string', self.postfix_hostname),
                    'postfix/destinations': (
                        'string',
                        '%s, localhost.localdomain, localhost ' %
                        (self.postfix_hostname),
                    )
                })
            install('postfix')

        # Update postfix conf
        custom_sudo("postconf -e 'virtual_alias_domains = regexp:%s'" %
                    (self.virtual_domains_regex_path))
        custom_sudo("postconf -e 'virtual_alias_maps = hash:%s'" %
                    (self.virtual_alias_path))

        # Restart postfix
        custom_sudo('service postfix restart')

        # Ensure the service is started
        started('postfix')
Exemplo n.º 11
0
def server(version='5.1'):
    """
    I can haz MySQL server
    """
    with settings(hide('warnings', 'stderr'), warn_only=True):
        result = sudo('dpkg-query --show mysql-server')

    if result.failed is False:
        warn('MySQL is already installed')
    else:
        mysql_password = prompt_password()

        preseed_package('mysql-server', {
            'mysql-server/root_password': ('password', mysql_password),
            'mysql-server/root_password_again': ('password', mysql_password),
        })

        package('mysql-server-%s' % version)

    started('mysql')
Exemplo n.º 12
0
def install_packages(pkgs, postfix_cfg):
    hostname = run('hostname')
    destination_cfg = '%s.clld.org, %s, localhost.localdomain, localhost', \
                      (hostname, hostname)

    deb.preseed_package(
        'postfix', {
            'postfix/main_mailer_type': ('select', 'Internet Site'),
            'postfix/mailname': ('string', hostname + '.clld.org'),
            'postfix/destinations': ('string', destination_cfg),
        })

    deb.install(pkgs)

    def fix_postfix_cfg():
        files.sed(postfix_cfg,
                  'myhostname = ',
                  'myhostname = ' + hostname + '.gwdg.de',
                  use_sudo=True)

    fix_postfix_cfg()
Exemplo n.º 13
0
def install():
    """ Installs Oracle Java JDK """

    print(green('Adding Oracle Java PPA'))
    cmd = 'add-apt-repository -y ppa:webupd8team/java'
    sudo(cmd)

    # update apt index
    deb.update_index(quiet=False)

    # package name
    java_pkg = 'oracle-java7-installer'

    print(green('Accepting Oracle license'))
    debconf_params = {
        'shared/accepted-oracle-license-v1-1': ('select', 'true')
    }
    deb.preseed_package(java_pkg, debconf_params)

    print(green('Installing Oracle Java 1.7'))
    utils.deb.install(java_pkg)
Exemplo n.º 14
0
def install(galera_nodes, cluster_name=None, password=None):
    """Install MariaDB Galera Cluster.

    :param galera_nodes: Do not include `gcomm://` prefix;
        See http://galeracluster.com/documentation-webpages/mysqlwsrepoptions.html#wsrep-cluster-address
    """
    if cluster_name is None:
        cluster_name = default_cluster_name

    install_fail2ban()

    require.deb.package('software-properties-common')
    require.deb.add_apt_key(keyid='0xcbcb082a1bb943db',
                            keyserver='hkp://keyserver.ubuntu.com:80',
                            update=False)  # we'll update after adding the repo
    run("add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mariadb.mirror.anstey.ca/repo/10.1/ubuntu trusty main'")
    require.deb.update_index(quiet=True)

    if password is None:
        password = getpass("Root password for mariadb (saved in ~/.my.cnf):")
    deb.preseed_package('mariadb-server', {
        'mysql-server/root_password': ('password', password),  # must be mysql, not mariadb here
        'mysql-server/root_password_again': ('password', password),
    })
    require.deb.install(['mariadb-server', 'galera-3'])

    put(files.galera_provider, '/var/tmp/')
    run('dpkg --install /var/tmp/{}'.format(files.galera_provider.name))
    upload_template(str(templates.my_cnf.name),
                    '/etc/mysql/my.cnf',
                    use_jinja=True,
                    template_dir=templates.dir,
                    context={'galera_nodes': galera_nodes,
                             'cluster_name': cluster_name})

    require.file('.my.cnf', mode="600", contents=(
        "[client]\n"
        "user=root\n"
        "password={}\n"
    ).format(password))
Exemplo n.º 15
0
    def install_postfix(self):
        # def install_postfix(mailname):
        """
        Require a Postfix email server.

        This makes sure that Postfix is installed and started.

        ::

            from fabtools import require

            # Handle incoming email for our domain
            require.postfix.server('example.com')

        """
        self.get_env()
        self.copy_mailgate_file()
        # Ensure the package is installed
        if not is_installed('postfix'):
            preseed_package('postfix', {
                'postfix/main_mailer_type': ('select', 'Internet Site'),
                'postfix/mailname': ('string', self.postfix_hostname),
                'postfix/destinations': (
                    'string', '%s, localhost.localdomain, localhost ' % (
                        self.postfix_hostname),)
            })
            install('postfix')

        # Update postfix conf
        custom_sudo("postconf -e 'virtual_alias_domains = regexp:%s'" % (
            self.virtual_domains_regex_path))
        custom_sudo("postconf -e 'virtual_alias_maps = hash:%s'" % (
            self.virtual_alias_path))

        # Restart postfix
        custom_sudo('service postfix restart')

        # Ensure the service is started
        started('postfix')
Exemplo n.º 16
0
def _server_debian(version, password):

    from fabtools.deb import is_installed, preseed_package
    from fabtools.require.deb import package as require_deb_package

    if version:
        pkg_name = 'mysql-server-%s' % version
    else:
        pkg_name = 'mysql-server'

    if not is_installed(pkg_name):
        if password is None:
            password = prompt('Please enter password for MySQL user "root":')

        with settings(hide('running')):
            preseed_package('mysql-server', {
                'mysql-server/root_password': ('password', password),
                'mysql-server/root_password_again': ('password', password),
            })

        require_deb_package(pkg_name)

    started('mysql')
Exemplo n.º 17
0
def _server_debian(version, password):

    from fabtools.deb import is_installed, preseed_package
    from fabtools.require.deb import package as require_deb_package

    if version:
        pkg_name = 'mysql-server-%s' % version
    else:
        pkg_name = 'mysql-server'

    if not is_installed(pkg_name):
        if password is None:
            password = prompt('Please enter password for MySQL user "root":')

        with settings(hide('running')):
            preseed_package(
                'mysql-server', {
                    'mysql-server/root_password': ('password', password),
                    'mysql-server/root_password_again': ('password', password),
                })

        require_deb_package(pkg_name)

    started('mysql')