40 lines
1.1 KiB
Python
40 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.value in key_machines.keys():
|
|
key_machines[key.value]=set()
|
|
for host in machine['host']:
|
|
key_machines[key.value].add(host.value)
|
|
domains=host.value.split('.')
|
|
key_machines[key.value].add(domains[0])
|
|
key_machines[key.value].add('.'.join(domains[0:2]))
|
|
for alias in machine['hostAlias']:
|
|
key_machines[key.value].add(alias.value)
|
|
domains=alias.value.split('.')
|
|
key_machines[key.value].add(domains[0])
|
|
key_machines[key.value].add('.'.join(domains[0:2]))
|
|
for ip in machine['ipHostNumber']:
|
|
key_machines[key.value].add("%s" % ip)
|
|
for ip in machine['ip6HostNumber']:
|
|
key_machines[key.value].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()
|
|
sys.stdout.write("".join(output))
|