41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
# -*- coding: utf-8; mode: python -*-
|
|
|
|
include("mode/space")
|
|
include("ldap_conn")
|
|
|
|
header("Configuration du serveur ssh")
|
|
|
|
|
|
machines=ldap_conn.search("objectClass=machineCrans")
|
|
|
|
|
|
key_machines={}
|
|
for machine in machines:
|
|
for key in machine['sshFingerprint']:
|
|
if not key in key_machines:
|
|
key_machines[key]=set()
|
|
for host in machine['host']:
|
|
key_machines[key].add(host.value)
|
|
domains=host.value.split('.')
|
|
key_machines[key].add(domains[0])
|
|
key_machines[key].add('.'.join(domains[0:2]))
|
|
for alias in machine['hostAlias']:
|
|
key_machines[key].add(alias.value)
|
|
domains=alias.value.split('.')
|
|
key_machines[key].add(domains[0])
|
|
key_machines[key].add('.'.join(domains[0:2]))
|
|
for ip in machine['ipHostNumber']:
|
|
key_machines[key].add("%s" % ip)
|
|
if len(machine.get('dnsIpv6', []))<1 or machine['dnsIpv6'][0].value:
|
|
for ip in machine['ip6HostNumber']:
|
|
key_machines[key].add("%s" % ip)
|
|
|
|
# On trie pour avoir des diff valident en appliquant bcfg2 sur les machines
|
|
output=[]
|
|
for key in key_machines.keys():
|
|
hosts=list(key_machines[key])
|
|
hosts.sort()
|
|
output.append("%s %s" % (','.join(hosts),key))
|
|
|
|
output.sort()
|
|
_out("\n".join(output))
|