Ejemplo n.º 1
0
#!/usr/bin/env python2

import os
import urlparse

from lib import metadata


query_string = urlparse.parse_qs(os.environ['QUERY_STRING'])
ip = query_string['ip'][0]
#client = metadata.lookup_ip(ip)
client, cm = metadata.find(ip)
network = metadata.network(client, cm)

print ''
with open('esxi/boot.cfg') as file:
  for line in file:
    if line.startswith('kernelopt='):
      print line.rstrip() + " vlanid=%s ip=%s netmask=%s gateway=%s nameserver=8.8.8.8" % (network.vlan, network.v4_address, network.v4_netmask, network.v4_gateway)
    else:
      print line

#print "vlanid=%s" % network.vlan
#print "ip=%s" % network.v4_address
#print "netmask=%s" % network.v4_netmask
#print "gateway=%s" % network.v4_gateway
Ejemplo n.º 2
0
from lib import metadata


def vault(host):
    fqdn = socket.getfqdn()
    cert = '/var/lib/puppet/ssl/certs/%s.pem' % fqdn
    key = '/var/lib/puppet/ssl/private_keys/%s.pem' % fqdn
    client = hvac.Client(url=host, cert=(cert, key))
    client.auth_tls()
    return client


# Move the secrets out of the directory that is kept in SVN
config = yaml.safe_load(file('/etc/deploy.yaml'))
client, _ = metadata.find(os.environ['REMOTE_ADDR'])

# Only enable crypto disks on event machines
is_event = client.domain == 'EVENT'
crypto = is_event
auto_unlock = True

blacklist = '01liIoO='
root_pw = base64.b64encode(os.urandom(11)).translate(None, blacklist)

if is_event:
    vault_path = 'services-{event}/login:{hostname}'
else:
    vault_path = 'services/login:{hostname}'

vault(config['vault-host']).write(vault_path.format(
Ejemplo n.º 3
0
#!/usr/bin/env python2
# Generate /etc/network/interfaces

import os
import urlparse

from lib import metadata

first_if = None
if 'QUERY_STRING' in os.environ:
    query_string = urlparse.parse_qs(os.environ['QUERY_STRING'])
    ifs = query_string['ifs'][0].split(',')
    first_if = ifs[0]

client, cm = metadata.find(os.environ['REMOTE_ADDR'], first_if)
network = metadata.network(
    client,
    cm,
)
if not network:
    exit(1)

if_template = (
    """# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source-directory interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback