Configurator

From UGCS
(Difference between revisions)
Jump to: navigation, search
(Basics)
(Adding a machine)
Line 38: Line 38:
 
==Examples==
 
==Examples==
 
===Adding a machine===
 
===Adding a machine===
<code><pre>
+
<pre>
 
from UgcsComputers import * # Load everything we need and some helpers
 
from UgcsComputers import * # Load everything we need and some helpers
 
load() # Read in machines.pck
 
load() # Read in machines.pck
Line 50: Line 50:
  
 
save() # Save the changes
 
save() # Save the changes
</code></pre>
+
</pre>
  
 
=Configuration scripts=
 
=Configuration scripts=

Revision as of 23:53, 28 April 2008

The configurator is a set of Python scripts and classes that keep track of various bits and pieces of information on all of our machines. This way, configuration files can be easily autogenerated.

Contents

Basics

The configuration consists of two python classes, UGCSHost and UGSCClass, in UgcsComputers. Each host is represented by a UGCSHost, and can have information set on it. It also may belong to several UGCSClasses. If a script requests some information from a host that it does not have, the host __getattr__ method will look through the classes in an attempt to find it. This way, you can set one piece of information for all hosts in a class easily (example: the 'shellsever' class has the property vlan='ugcs-shell', so any computer that belongs to that class has the property vlan='ugcs-shell' ) The list of classes, hosts, etc is saved in a python pickle dump in /afs/ugcs/ugcs-admin/configurator/machines.pck

Demeter then runs a cron script once an hour that checks for updates to this file. (/etc/cron.hourly/update-cfengine) If it has, it uses the configurator generator scripts to update the configuration files in cfengine. You can then use cfrun from demeter to update each machine (except for vmps on charon)

UgcsComputers module documentation

UGCSHost

Properties

  • ip
  • mac
  • name

UGCSClass

  • UGCSClass(classname, priority)

Methods

  • load()
  • save()
  • get_host(hostname)
  • get_hosts
  • remove_host(hostname)
  • rename_host(from, to)
  • get_class(classname)
  • get_classes

How to use

To edit the configuration, start up python in /afs/ugcs/ugcs-admin/configurator and:

from UgcsComputers import * # Load everything we need and some helpers
load() # Read in machines.pck
# Do stuff here
save() # Save the changes

Examples

Adding a machine

from UgcsComputers import * # Load everything we need and some helpers
load() # Read in machines.pck

h = UGCSHost('newshellserver')
h.ip = '131.215.176.ip'
h.mac = 'h-mac-addr-with-dashes'
h.add_class('ugcs')
h.add_class('shellserver')
h.add_class('puke-ro')

save() # Save the changes

Configuration scripts

None of the configuration scripts currently overwrite any files; you must pipe them to the file (or use <script> | sudo tee file) if you want them to actually do something.

create_vmps_db.py

Creates the vmps db for charon. This is typically run on charon; you must scp machines.pck to root@charon:/root/, ssh into charon, and run /root/create_vmps_db.py . It adds all the computers in the classes coreserver, shellserver, and hosted.

generate-demeter-exports.py

Creates the autogenerated part of /etc/exports on demeter. It add /etc/exports.input at the end for static exports. It uses machines from the classes puke-ro and puke-rw, and gets nfs mount information from <host>.nfsmouts, which should be a list of tuples (export, params). If export contains '%s', it is replace with the machine name (just once). Params should typically include ro or rw, no_subtree_check, and no_root_squash.

generate_bind_db.py, generate_bind_rdns.py

These two generate db.ugcs.caltech.edu and db.176.215.131 for bind on demeter. Both use all the hosts and do not care about classes. generate_bind_rdns.py looks for all ips, and if one doesn't exist, substitutes addr-<tail> for the rdns name. generate_bind_db.py uses the classes coreserver, shellserver, and hosted. If a host has extra_dns set, the contents of extra_dns (either a string or a list) will be added after the A record. generate_bind_db.py also looks in /etc/bind/db.ugcs.caltech.edu.input for static stuff (CNAMES,etc), but outputs the header itself.

generate_dhcpd_conf

This generates the dhcpd configuration file for demeter. It takes the classname to generate the conf file for as an argument on the command line. It also only writes the part with the host definitions, so the file that this is saved to must be included from dhcpd.conf. It is typically used like:

./generate_dhcpd_conf.py shellserver | sudo tee /etc/dhcp/pukes.conf
Personal tools