Python Admin Scripts

Gerhard Häring gh at ghaering.de
Thu Mar 27 12:38:01 EST 2003


* Norm <normjunk at yahoo.com> [2003-03-27 09:12 -0800]:
> Many of you must be Linux/NT admins.  What I am looking for are
> projects to try out on Python.

I've only recently come into the admin field - I'm normally a software
developer.

> How have you found Python to be useful in making the job easier?
> 
> What tasks have you automated with Python?

A bare-bone ISP management software (not finished yet, but functional).
What I've got now is a script that creates:

- Apache virtual hosts
- Virtual Courier IMAP/POP3 users and their respective mailboxes
- Virtual domains for Postfix and the configuration for the virtual
  users
- user logins for SMTP/AUTH

in 159 lines of code.

The dominant practise seems to be to centralize the user administration
in a LDAP or MySQL database. I, however, keep all relevant information
in a PostgreSQL database, then use a script that uses the various
Postfix/Courier tools to write Berkeley db files. This is more
lightweight and I don't have to touch either LDAP or MySQL, which I'm
happy of :-)

It uses pyPgSQL for accessing PostgreSQL, os.popen2 and os.system to
interface external programs.

This already saved me lots of manual work, and the plan is to make it
much more comfortable by

- converting the script to a daemon, that will likely use LISTEN to wait
  for PostgreSQL notifications. These can be sent by TRIGGERs on various
  database tables. Or I could just use XML-RPC, but exploiting all
  PostgreSQL features would be cool :-)

- a web frontend for the database, which I've sort of begun using
  Webware

Of course there are TONS of similar tools on the net (ispman, written in
PERL, seemed the best suited for my use case), but especially for system
administration, I want to know *exactly* what's going on, I want to be
able to hack it myself and that's why I've decided to write my own tool.

Gerhard
-- 
mail:   gh at ghaering.de
web:    http://ghaering.de/





More information about the Python-list mailing list