Exemple #1
0
def _generate_client(host):
    info = {}
    servers = lib.get_servers_for_node('ntpd', host)

    # Use local servers if available
    if servers:
        info['servers'] = servers

    return info
Exemple #2
0
def generate(host, *args):

    current_event = lib.get_current_event()

    ldap_server = sorted(lib.get_servers_for_node('ldap', host))[0]

    info = {}
    info['current_event'] = current_event
    info['ldap_server'] = ldap_server

    return {'obsdlogin': info}
Exemple #3
0
def generate(host):
    info = {}

    resolvers = lib.get_servers_for_node('eventdns', host)
    ips = lib.resolve_nodes_to_ip(resolvers)
    info['nameservers'] = [ips[x][0] for x in resolvers]

    info['icmp_target'] = 'ping.sunet.se'
    info['dns_target'] = 'slashdot.org.'

    return {'observer': info}
Exemple #4
0
def generate(host, *args):
    my_domain = lib.get_domain(host)

    info = {}

    my_dns_domain = '.'.join(host.split('.')[1:])

    info['domain'] = my_dns_domain

    # Some things (busybox? musl?) doesn't work well with multiple searchs.
    # Let's use only the primary one for now
    info['search'] = [my_dns_domain]

    if my_domain == 'EVENT':
        resolvers = lib.get_servers_for_node('eventdns', host)
    else:
        resolvers = lib.get_servers_for_node('dns', host)

    # Sort to lexographical order (e.g. ddns1 before ddns3)
    resolvers = sorted(resolvers)

    info['nameservers'] = []

    # Do not use ourself if we are a resolver.
    if host in resolvers:
        resolvers.remove(host)
        # Use an external resolver by default so we do not create deadlocks
        # when bootstrapping the environment from scratch.
        info['nameservers'].append('1.1.1.1')

    ips = lib.resolve_nodes_to_ip(resolvers)
    info['nameservers'].extend([ips[x][0] for x in resolvers])

    # Default to Google DNS
    info['nameservers'].extend(['8.8.8.8', '8.8.4.4'])

    # Only three, no support for more in Linux
    info['nameservers'] = info['nameservers'][:3]
    return {'resolvconf': info}
Exemple #5
0
def generate(host):
    my_domain = lib.get_domain(host)

    # Only run promtail on event servers
    if not my_domain == 'EVENT':
        return {}

    loki_servers = lib.get_servers_for_node('loki', host)
    if len(loki_servers) == 0:
        # If no loki servers are configured, do not setup promtail
        return {}

    def build_uri(server):
        return "http://{}:3100/loki/api/v1/push".format(server)

    info = {}
    info['loki_uris'] = map(build_uri, loki_servers)
    return {'promtail': info}
Exemple #6
0
def generate(host, *args):

    if 'local' in args:
        local = 1
    else:
        local = 0

    private_zones = [
        '10.in-addr.arpa',
        '16.172.in-addr.arpa',
        '17.172.in-addr.arpa',
        '18.172.in-addr.arpa',
        '19.172.in-addr.arpa',
        '20.172.in-addr.arpa',
        '21.172.in-addr.arpa',
        '22.172.in-addr.arpa',
        '23.172.in-addr.arpa',
        '24.172.in-addr.arpa',
        '25.172.in-addr.arpa',
        '26.172.in-addr.arpa',
        '27.172.in-addr.arpa',
        '28.172.in-addr.arpa',
        '29.172.in-addr.arpa',
        '30.172.in-addr.arpa',
        '31.172.in-addr.arpa',
        '168.192.in-addr.arpa',
        'event.dreamhack.local',
    ]

    stub_hosts = lib.get_servers_for_node('resolver', host)

    stub_hosts.sort()

    info = {}
    info['private_zones'] = private_zones
    info['stub_hosts'] = stub_hosts
    info['local'] = local
    return {'unbound': info}
Exemple #7
0
def generate(host, *args):

    # Decide if we are the active node:
    if 'active' in args:
        active = 1
    else:
        active = 0

    # Get fqdn of active node
    active_node = 'dhcp1.event.dreamhack.se'
    for (k, v) in lib.get_nodes_with_package('dhcpd',
                                             lib.get_domain(host)).items():
        if v == [u'active']:
            active_node = k
            break

    # Fetch DHCP scopes
    scopes = lib.sqlite2dhcp_scope.App(['-', '/etc/ipplan.db',
                                        '-']).run_from_puppet()

    # Get the subnet the dhcpd lives at in CIDR notation
    local_subnet_cidr = lib.get_ipv4_network(host)[0]
    local_subnet = local_subnet_cidr.split('/')[0]
    local_cidr = int(local_subnet_cidr.split('/')[1])

    # Convert CIDR to netmask
    bitmask = 0xffffffff ^ (1 << 32 - local_cidr) - 1
    local_netmask = inet_ntop(AF_INET, pack('!I', bitmask))

    # Set ntp-servers
    ntp_servers = ", ".join(lib.get_servers_for_node('ntpd', host))
    if not ntp_servers:
        ntp_servers = ('0.pool.ntp.org, '
                       '1.pool.ntp.org, '
                       '2.pool.ntp.org, '
                       '3.pool.ntp.org')

    # Set domain-name-servers
    resolver_ipv4_addresses = []
    for hostname, addresses in lib.resolve_nodes_to_ip(
            lib.get_servers_for_node('resolver', host)).iteritems():

        resolver_ipv4_addresses.append(addresses[0])

    resolver_ipv4_addresses.sort()
    domain_name_servers = ", ".join(resolver_ipv4_addresses)

    if not domain_name_servers:
        domain_name_servers = '8.8.8.8, 8.8.4.4'

    # Set tftp-server-name
    tftp_server_name_address = lib.resolve_nodes_to_ip(
        ['pxe.event.dreamhack.se'])
    tftp_server_name = tftp_server_name_address['pxe.event.dreamhack.se'][0]

    # Set next-server
    next_server_addresses = lib.resolve_nodes_to_ip(['pxe.event.dreamhack.se'])
    next_server = next_server_addresses['pxe.event.dreamhack.se'][0]

    # Get current event, used to decide name of dhcpinfo database
    current_event = lib.get_current_event()

    info = {}
    info['active'] = active
    info['active_node'] = active_node
    info['scopes'] = scopes
    info['ntp_servers'] = ntp_servers
    info['domain_name_servers'] = domain_name_servers
    info['tftp_server_name'] = tftp_server_name
    info['next_server'] = next_server
    info['local_subnet'] = local_subnet
    info['local_netmask'] = local_netmask
    info['current_event'] = current_event

    return {'dhcpd': info}
Exemple #8
0
def generate(host, *args):
    syslog_servers = lib.get_servers_for_node('syslogd', host)

    info = {}
    info['syslog_servers'] = list(syslog_servers) + list(args)
    return {'syslog': info}