Пример #1
0
def configure_aiccu(path=None):
    "Configures aiccu. Hartbeat monitor for sixxs ipv6 tunnel"
    opts = dict(
        path=path or env.get('path') or err("env.path must be set"),
    )

    upload_template_jinja2("%(path)s/etc/aiccu.conf" % opts, "/etc/aiccu.conf")
    sudo("/etc/init.d/aiccu restart")
    sudo("update-rc.d aiccu defaults")
Пример #2
0
def configure_bacula_client(path=None):
    """Upload configuration for Bacula File Deamon (client)
    and restart it."""
    opts = dict(
        path=path or env.get('path') or err('env.path must be set'),
    )

    upload_template_jinja2('%(path)s/etc/bacula-fd.conf' % opts, '/etc/bacula/bacula-fd.conf', use_sudo=True)
    sudo('service bacula-fd restart')
Пример #3
0
def configure_nginx(path=None):
    """Upload Nginx configuration and restart Nginx so this configuration takes
    effect."""
    opts = dict(
        path=path or env.get('path') or err("env.path must be set"),
    )

    if os.path.exists("%(path)s/etc/nignx/nginx.conf"):
        upload_template_jinja2("%(path)s/etc/nignx/nginx.conf" % opts,
                '/etc/nginx/nginx.conf', use_sudo=True)
        sudo('service nginx restart')
Пример #4
0
def configure_dnsmasq(path=None):
    """
    Configures local dns server

    :param path: Template folder
    :type path: str
    """
    opts = dict(
        path=path or env.get('path') or err("env.path must be set"),
    )

    upload_template_jinja2("%(path)s/etc/dnsmasq.con" % opts,
            '/etc/dnsmasq.conf', use_sudo=True)
    sudo('service nginx restart')
Пример #5
0
def add_to_bacula_master(shortname=None, path=None, bacula_host_string=None):
    """Add this server's Bacula client configuration to Bacula master."""
    opts = dict(
        shortname=shortname or env.get('shortname') or err('env.shortname must be set'),
        path=path or env.get('path') or err('env.path must be set'),
        bacula_host_string=bacula_host_string or env.get('bacula_host_string') or err('env.bacula_host_string must be set')
    )

    with settings(host_string=opts['bacula_host_string']):

        # upload project-specific configuration
        upload_template_jinja2(
            '%(path)s/etc/bacula-master.conf' % opts,
            '/etc/bacula/clients/%(shortname)s.conf' % opts,
            use_sudo=True)

        # reload bacula master configuration
        sudo("service bacula-director restart")
Пример #6
0
def install_network_config(path=None):
    """
    Installs network configuration, using jinja2 template and adds networking to
    startup.

    .. note:: This function won't restart your network by itself.

    :param path: Path to your template folder
    :type path: str
    """

    opts = dict(
            path=path or env.get("path") or err('env.path must be set')
            )

    upload_template_jinja2("%(path)/etc/network/interfaces" % opts,
                           "/etc/network/interfaces")
    add_startup("networking")
Пример #7
0
def install_badvpn(path=None):
    """Installs and configures badvpn client and server"""
    opts= dict(
            cert_folder = "/etc/badvpn/nssdb",
            path=path or env.get('path') or err('env.path must be set')
            )

    """Install package"""
    core.apt_get("badvpn","ppa:ambrop7/badvpn")
    core.apt_get(["libnss3-tools"])

    """Install all configs"""
    sudo("cp /etc/init.d/badvpn-server /etc/init.d/badvpn-client")
    upload_template_jinja2("%(path)s/etc/init/badvpn-client" % opts,
             "/etc/init/badvpn-client", use_sudo=True)
    dir_ensure(opts["cert_folder"], recursive=True)
    upload_template_jinja2("%(path)s/etc/badvpn/badvpn-client" % opts,
             "/etc/badvpn/badvpn-client", use_sudo=True)
    sudo("ln -s /etc/badvpn/badvpn-client /etc/default/badvpn-client")
    upload_template_jinja2("%(path)s/etc/badvpn/badvpn-server" % opts,
             "/etc/badvpn/badvpn-server", use_sudo=True)
    sudo("ln -s /etc/badvpn/badvpn-server /etc/default/badvpn-server")

    """Create cert database"""
    put("%(path)s/ca.pem" % opts, "~/")
    sudo("certutil -d sql:%(cert_folder)s -N" % opts)
    sudo('certutil -d sql:%(cert_folder)s -A -t "CT,," -n "vpnca" -i ~/ca.pem' % opts)
Пример #8
0
def configure_bacula_master(path=None):
    """Upload configuration files for Bacula Master."""
    opts = dict(
        path=path or env.get('path') or err('env.path must be set'),
    )

    upload_template_jinja2('%(path)s/etc/bacula-dir.conf' % opts,
                    '/etc/bacula/bacula-dir.conf',
                    use_sudo=True)
    upload_template_jinja2('%(path)s/etc/pool_defaults.conf' % opts,
                    '/etc/bacula/pool_defaults.conf',
                use_sudo=True)
    upload_template_jinja2('%(path)s/etc/pool_full_defaults.conf' % opts,
                '/etc/bacula/pool_full_defaults.conf',
                use_sudo=True)
    upload_template_jinja2('%(path)s/etc/pool_diff_defaults.conf' % opts,
                '/etc/bacula/pool_diff_defaults.conf',
                use_sudo=True)
    upload_template_jinja2('%(path)s/etc/pool_inc_defaults.conf' % opts,
                '/etc/bacula/pool_inc_defaults.conf',
                use_sudo=True)

    sudo('service bacula-director restart')
Пример #9
0
def configure_finch(home=None, username=None):
    """Configures finch, console client port of pidign"""
    opts = dict(
        home=home or env.get('home') or err("env.home must be set"),
        username=username or env.get('username') or err("env.username must be set")
    )

    #Account and preferences
    dir_ensure("/home/%(username)s/.purple" % opts)
    upload_template_jinja2("%(home)s/.purple/prefs.xml" % opts, 
            "/home/%(username)s/.purple/prefs.xml" % opts)
    upload_template_jinja2("%(home)s/.purple/accounts.xml" % opts, 
            "/home/%(username)s/.purple/accounts.xml" % opts)

    #Mouse support
    upload_template_jinja2("%(home)s/.gntrc" % opts, "/home/%(username)s/.gntrc" % opts)
Пример #10
0
def upload_template(location, use_sudo=True):
    """
    Uploads template using jinja2

    Idea is that your local template is located in a same relative path as on
    remote side. To make this work you have to set `env.path` to your location
    of templates.

    .. note::
        This function should be called as task using execute fabric api.
        Otherwise use :py:func:`easydeploy.core.upload_template_jinja2`.

    :param location: Local and remote path to template
    :type location: str
    :param use_sudo: Should we use sudo
    :type use_sudo: bool

    :returns: Whatever upload_template returns
    """

    path= env.get("path") or err("env.path must be set")
    return upload_template_jinja2(os.path.join(path,location), location, use_sudo)
Пример #11
0
def configure_avahi(path=None):
    """Configure avahi for mdns support"""
    opts = dict(
        path = path or env.get("path") or err("env.path must be set")
    )

    upload_template_jinja2("%(path)s/etc/avahi/avahi-daemon.conf" % opts,
                    "/etc/avahi/avahi-daemon.conf")

    #Allow other domains
    upload_template_jinja2("%(path)s/etc/mdns.allow" % opts,
                    "/etc/mdns.allow")

    #For ipv6 mdns support
    upload_template_jinja2("%(path)s/etc/nsswitch.conf" % opts,
                    "/etc/nsswitch.conf")

    sudo("service avahi-daemon restart")