Esempio 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')
Esempio n. 2
0
def server(version=None):
    """
    Require a PostgreSQL server to be installed and running.

    ::

        from fabtools import require

        require.postgres.server()

    """
    if version:
        pkg_name = 'postgresql-%s' % version
    else:
        pkg_name = 'postgresql'
    package(pkg_name)

    if is_file('/etc/init.d/postgresql'):
        service_name = 'postgresql'
    else:
        if version and is_file('/etc/init.d/postgresql-%s' % version):
            service_name = 'postgresql-%s' % version
        else:
            with cd('/etc/init.d'):
                with settings(hide('running', 'stdout')):
                    service_name = run('ls postgresql-*').splitlines()[0]
    started(service_name)
Esempio 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')
Esempio 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_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")
Esempio n. 5
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')
Esempio n. 6
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')
Esempio n. 7
0
def server(version=None):
    """
    Require a PostgreSQL server to be installed and running.

    ::

        from fabtools import require

        require.postgres.server()

    """
    if version:
        pkg_name = 'postgresql-%s' % version
    else:
        pkg_name = 'postgresql'
    package(pkg_name)

    if is_file('/etc/init.d/postgresql'):
        service_name = 'postgresql'
    else:
        if version and is_file('/etc/init.d/postgresql-%s' % version):
            service_name = 'postgresql-%s' % version
        else:
            with cd('/etc/init.d'):
                with settings(hide('running', 'stdout')):
                    service_name = run('ls postgresql-*').splitlines()[0]
    started(service_name)
Esempio n. 8
0
def server(version='8.4'):
    """
    Require a PostgreSQL server
    """
    package('postgresql-%s' % version)
    service = 'postgresql-%s' % version
    if not is_file(os.path.join('/etc/init.d', service)):
        service = 'postgresql'
    started(service)
Esempio n. 9
0
def server():
    """
    Require apache2 server to be installed and running.

    ::

        from fabtools import require
        require.apache2.server()
    """
    package("apache2")
    started("apache2")
Esempio n. 10
0
def server(version=None):
    """
    Require a PostgreSQL server
    """
    if version:
        pkg_name = service_name = 'postgresql-%s' % version
    else:
        pkg_name = service_name = 'postgresql'
    package(pkg_name)
    if not is_file(os.path.join('/etc/init.d', service_name)):
        service_name = 'postgresql'
    started(service_name)
Esempio n. 11
0
def _server_debian(version):

    from fabtools.require.deb import package as require_deb_package

    if version:
        pkg_name = 'postgresql-%s' % version
    else:
        pkg_name = 'postgresql'

    require_deb_package(pkg_name)

    started(_service_name(version))
Esempio n. 12
0
def server():
    """
    Require nginx server to be installed and running.

    ::

        from fabtools import require

        require.nginx.server()
    """
    package('nginx')
    started('nginx')
Esempio n. 13
0
def _server_debian(version):

    from fabtools.require.deb import package as require_deb_package

    if version:
        pkg_name = "postgresql-%s" % version
    else:
        pkg_name = "postgresql"

    require_deb_package(pkg_name)

    started(_service_name(version))
Esempio n. 14
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')
Esempio n. 15
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')
Esempio n. 16
0
def server(version=None):
    """
    Require a PostgreSQL server to be installed and running.

    ::

        from fabtools import require

        require.postgres.server()

    """
    if version:
        pkg_name = 'postgresql-%s' % version
    else:
        pkg_name = 'postgresql'
    package(pkg_name)

    started(_service_name(version))
Esempio n. 17
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')
Esempio n. 18
0
def server(version=None):
    """
    Require a PostgreSQL server to be installed and running.

    ::

        from fabtools import require

        require.postgres.server()

    """
    if version:
        pkg_name = 'postgresql-%s' % version
    else:
        pkg_name = 'postgresql'
    package(pkg_name)

    started(_service_name(version))
Esempio n. 19
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')
    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')
Esempio n. 21
0
def server(version=None):
    """
    Require a PostgreSQL server to be installed and running.

    ::

        from fabtools import require

        require.postgres.server()

    """
    if distrib_family() == "arch":
        pkg_name = 'postgresql'
        arch.package(pkg_name)
        init_postgres()
    else:
        if version:
            pkg_name = 'postgresql-%s' % version
        else:
            pkg_name = 'postgresql'
        package(pkg_name)

    started(_service_name(version))
Esempio n. 22
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')
Esempio n. 23
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')
Esempio n. 24
0
def server():
    """
    Require an nginx server
    """
    package('nginx')
    started('nginx')
Esempio n. 25
0
def _install_apache():
    from fabtools.require.service import started
    from fabtools.require.apache import server
    server()
    started('apache2')
Esempio n. 26
0
def _install_apache():
    from fabtools.require.service import started
    from fabtools.require.apache import server
    server()
    started('apache2')
Esempio n. 27
0
def server():
    package('apache2')
    started('apache2')
Esempio n. 28
0
def server():
    """
    Require an nginx server
    """
    package('nginx')
    started('nginx')
Esempio n. 29
0
def install_apache():
    from fabtools.require.service import started
    from fabtools.require.apache import server
    set_hostname('www.example.com')
    server()
    started('apache2')