示例#1
0
def timezone(timezone=config.get("ntp_client", {}).get("ntp_timezone", "Asia/Calcutta")):
    """ Set the timezone. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
    
    import apt
    apt.ensure(tzdata="latest")
    return run("cp -f /usr/share/zoneinfo/%s /etc/localtime" % timezone)
示例#2
0
def ensure(**kwargs):
    """ Ensure that the hostname for each host is set correctly according to parameters. """
    if env.host in kwargs:
        if is_debian_or_ubuntu():
            run("""echo "%s" > /etc/hostname""" % kwargs[env.host])
            run("""sysctl kernel.hostname=%s""" % kwargs[env.host])
            
            import service
            svc = {"hostname.sh":"restarted"}
            service.ensure(**svc)
示例#3
0
def configure(server=config.get("ntp_client", {}).get("ntp_server", "")):
    """ Configure NTP sync to server. """
    
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
    
    # Upload configuration
    params = {'server':server}
    reconfigure("ntp_client.conf.template", params, NTP_CONF_PATH)
示例#4
0
def configure(server=config.get("ntp_client", {}).get("ntp_server", "")):
    """ Configure NTP sync to server. """

    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return

    # Upload configuration
    params = {'server': server}
    reconfigure("ntp_client.conf.template", params, NTP_CONF_PATH)
示例#5
0
def configure(**kwargs):
    """ Configure SNMP on the server. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
    params = copy.copy(config['snmp'])
    params.update(kwargs)
    
    reconfigure("snmpd.conf.template", params, SNMPD_CONF_PATH)
    reconfigure("snmpd.template", params, SNMPD_PATH)
示例#6
0
def timezone(timezone=config.get("ntp_client", {}).get("ntp_timezone",
                                                       "Asia/Calcutta")):
    """ Set the timezone. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return

    import apt
    apt.ensure(tzdata="latest")
    return run("cp -f /usr/share/zoneinfo/%s /etc/localtime" % timezone)
示例#7
0
def ensure(**kwargs):
    """ Ensure that the hostname for each host is set correctly according to parameters. """
    if env.host in kwargs:
        if is_debian_or_ubuntu():
            run("""echo "%s" > /etc/hostname""" % kwargs[env.host])
            run("""sysctl kernel.hostname=%s""" % kwargs[env.host])

            import service
            svc = {"hostname.sh": "restarted"}
            service.ensure(**svc)
示例#8
0
def deploy():
    """ Install and configure and start cups client. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
    
    import apt, service
    packages = {"cupsys":"latest", "cups-client":"latest"}
    apt.ensure(**packages)
    configure()
    service.ensure(cupsys="restarted")
示例#9
0
def deploy(server=config.get("syslog_client", {}).get("syslog_server", ""),
           proto=config.get("syslog_client", {}).get("syslog_proto", ""),
           port=config.get("syslog_client", {}).get("syslog_port", ""),
           scope=config.get("syslog_client", {}).get("syslog_scope", "")):
    """ Configure and re-start syslog. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return

    with cd("/etc/init.d"):
        svcn = run("ls -1 *sys*log*")
        svcn = svcn.split("\n")[0]

    if exists("/etc/syslog.conf"):
        conf = "/etc/syslog.conf"
    elif exists("/etc/rsyslog.conf"):
        conf = "/etc/rsyslog.conf"

    with hide("running", "stdout", "stderr"):
        config = run("cat %s" % conf)
    line = "%s  %s%s:%s" % (scope, "@@" if proto == "tcp" else "@", server,
                            port)

    if config.find(server) > -1:
        # Check if current config matches existing config
        if config.find(line) > -1:
            print green("%s: No changes necessary" % env.host)
            return True
        else:
            config_lines = config.split("\n")
            for i, l in enumerate(config_lines):
                if l.find(server) > -1:
                    config_lines[i] = line
                    break
            config = "\n".join(config_lines)
            config += "\n"
    else:
        config = ("\n" + line + "\n") + config
        config = config.replace("\n\n", "\n")

    fn = os.path.join("templates", uuid.uuid1().hex)

    with open(fn, "wb") as outf:
        outf.write(config)

    # Put the file on the server
    upload_template(fn, conf)
    os.remove(fn)

    kw = {}
    kw[svcn] = "restarted"
    import service
    service.ensure(**kw)
示例#10
0
def deploy(server=config.get("syslog_client", {}).get("syslog_server", ""),
            proto=config.get("syslog_client", {}).get("syslog_proto", ""),
            port=config.get("syslog_client", {}).get("syslog_port", ""),
            scope=config.get("syslog_client", {}).get("syslog_scope", "")):
    """ Configure and re-start syslog. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
    
    with cd("/etc/init.d"):
        svcn = run("ls -1 *sys*log*")
        svcn = svcn.split("\n")[0]
        
    if exists("/etc/syslog.conf"):
        conf = "/etc/syslog.conf"
    elif exists("/etc/rsyslog.conf"):
        conf = "/etc/rsyslog.conf"
    
    with hide("running", "stdout", "stderr"):
        config = run("cat %s" % conf)
    line = "%s  %s%s:%s" % (scope, "@@" if proto == "tcp" else "@", server, port)
    
    if config.find(server) > -1:
        # Check if current config matches existing config
        if config.find(line) > -1:
            print green("%s: No changes necessary" % env.host)
            return True
        else:
            config_lines = config.split("\n")
            for i, l in enumerate(config_lines):
                if l.find(server) > -1:
                    config_lines[i] = line
                    break
            config = "\n".join(config_lines)
            config += "\n"
    else:
        config = ("\n" + line + "\n") + config
        config = config.replace("\n\n", "\n")
    
    fn = os.path.join("templates", uuid.uuid1().hex)
    
    with open(fn, "wb") as outf:
        outf.write(config)
    
    # Put the file on the server
    upload_template(fn, conf)
    os.remove(fn)
    
    kw = {}
    kw[svcn] = "restarted"
    import service
    service.ensure(**kw)
示例#11
0
def deploy():
    """ Install, configure and start snmpd. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
    
    import apt, service
    packages = {"snmpd":"latest"}
    if run("cat /etc/issue").find("6.0") > -1:
        # its debian 6
        packages["snmp-mibs-downloader"] = "installed"
        
    apt.ensure(**packages)
    
    configure()
    service.ensure(snmpd="restarted")
示例#12
0
def deploy(server=config.get("ntp_client", {}).get("ntp_server", "")):
    """ Install, configure and start ntp sync and timezone. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
        
    import apt, service
    packages = {"ntp":"latest", "ntpdate":"latest"}
    apt.ensure(**packages)
    configure()
    
    # Sync with server
    run("ntpdate %s" % server)
    
    # Sync hardware clock to correct time
    run("hwclock --systohc")
    
    service.ensure(ntp="restarted")
    timezone()
示例#13
0
def deploy(server=config.get("ntp_client", {}).get("ntp_server", "")):
    """ Install, configure and start ntp sync and timezone. """
    if not is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return

    import apt, service
    packages = {"ntp": "latest", "ntpdate": "latest"}
    apt.ensure(**packages)
    configure()

    # Sync with server
    run("ntpdate %s" % server)

    # Sync hardware clock to correct time
    run("hwclock --systohc")

    service.ensure(ntp="restarted")
    timezone()
示例#14
0
def deploy():
    """ Install, configure and start webmin. """
    
    if not utils.is_debian_or_ubuntu():
        print red("Cannot deploy to non-debian/ubuntu host: %s" % env.host)
        return
        
    # Check if webmin is installed
    installed, upgradeable = apt.status("webmin")
    if not installed:
        packages = {
            "libnet-ssleay-perl":"latest",
            "libauthen-pam-perl":"latest",
            "libio-pty-perl":"latest",
            "libmd5-perl":"latest"
        }
        apt.ensure(**packages)
        download()
        install()
    
    service.ensure(webmin="running")