[secret, dhcp] La configuration d'un dhcp est entièrement automatisé
En particulier grâce à la génération des clefs omapi directement sur bcfg2
This commit is contained in:
parent
0b37a791f7
commit
49dd2f9c4d
5 changed files with 19 additions and 6 deletions
6
Python/etc/crans/secrets/dhcp.py
Normal file
6
Python/etc/crans/secrets/dhcp.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
info["perms"] = 0440
|
||||
info["group"] = "adm"
|
||||
import dhcp
|
||||
|
||||
print "dhcp_omapi_keyname = '%s'" % dhcp.dhcp_omapi_keyname
|
||||
print "dhcp_omapi_keys = %s" % dhcp.dhcp_omapi_keys
|
|
@ -8,7 +8,17 @@ comment_start = "#"
|
|||
|
||||
header("Configuration pour omapi pour %s" % admhostname)
|
||||
|
||||
include("secrets")
|
||||
import dhcp
|
||||
import os
|
||||
import base64
|
||||
|
||||
if not dhcp.dhcp_omapi_keys.get(admhostname, False):
|
||||
host = admhostname
|
||||
key = base64.encodestring(os.urandom(64)).replace('\n','')
|
||||
with open('/etc/crans/secrets/dhcp/dhcp.key', 'a+') as f:
|
||||
f.write("%s %s\n" % (host, key))
|
||||
f.close()
|
||||
reload(dhcp)
|
||||
|
||||
print """
|
||||
omapi-port 9991;
|
||||
|
@ -18,4 +28,4 @@ key omapi_key {
|
|||
};
|
||||
|
||||
omapi-key omapi_key;
|
||||
""" % secrets.dhcp_omapi_keys.get(admhostname, '')
|
||||
""" % dhcp.dhcp_omapi_keys.get(admhostname, '')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue