Writing Python framework for declarative checks?

Victor Hooi victorhooi at gmail.com
Mon Mar 18 21:38:59 CET 2013


NB: I've posted this question on Reddit as well (but didn't get many responses from Pythonistas) - hope it's ok if I post here as well.

We currently use a collection of custom Python scripts to validate various things in our production environment/configuration.

Many of these are simple XML checks (i.e. validate that the value of this XML tag here equals the value in that file over there). Others might be to check that a host is up, or that this application's crontab start time is within 20 minutes of X, or that a logfile on a server contains a certain line.

The checks are executed automatically before every production push.

The scripts are written imperatively. E.g.:

SSH into a server
Open up a file
Parse the XML
Search for a XML tag
Store the value in a variable
Compare it to another value somewhere else.
I'd like to look at writing a framework to do these validation in a slightly more declarative way - i.e. instead of defining how the server should check something, we should just be able to say <tag>value</tag> should equal foobar - and let the framework handle the how.

I was thinking we could then schedule the checks and shove the jobs onto a queue like Celery.

To stop me from re-inventing the wheel - are there any existing projects that do something like this already?

Or has anybody here done something similar, or would be able to offer any advice?

(I aware of things like Puppet or Chef - or even Salt Stack - however, these are for managing deployments, or actually pushing out configurations. These validation scripts are more to ensure that the configuration changes done by hand are sane, or don't violate certain basic rules).


More information about the Python-list mailing list