NAME

Provision::Unix - provision accounts on unix systems

VERSION

Version 0.27

SYNOPSIS

Provision::Unix is an application to create, modify, and destroy accounts on Unix systems in a reliable and consistent manner.

prov_user.pl --create --username=matt --pass='neat0app!'
prov_dns.pl  --create --zone=example.com
prov_web.pl  --create --vhost=www.example.com

The types of accounts that can be provisioned are organized by class with each class including a standard set of operations. All classes support at least create and destroy operations. Additional common operations are: modify, suspend, restore.

Each class (DNS, Mail, User, VirtualOS, Web) has a general module that contains the logic for selecting and dispatching requests to sub-classes which are implementation specific. Selecting and dispatching is done based on the environment and configuration file settings at run time.

For example, Provision::Unix::Mail contains all the general logic for email operations (create a vhost, mailbox, alias, etc). Subclasses contain specific information such as how to provision a mailbox for sendmail, postfix, qmail, ezmlm, or vpopmail.

Browse the perl modules to see which modules are available.

use Provision::Unix;

my $foo = Provision::Unix->new();
...

Programming Conventions

All functions/methods adhere to the following:

Exception Handling

Errors throw exceptions. This can be overridden by calling the method with fatal=>0. If you do so, you must write code to handle the errors.

This call will throw an exception since it cannot find the file.

$util->file_read(file=>'/etc/oopsie_a_typo');

Setting fatal will cause it to return undef instead:

$util->file_read(file=>'/etc/oopsie_a_typo', fatal=>0);

Warnings and Messages

Methods have an optional debug parameter that defaults to enabled. Often, that means methods spit out more messages than you want to see. While this is helpful at first, it quickly gets annoying so you can pass along debug=>0 to surpress them.

Lucky for you, the messages aren't lost! All error messages are stored in $prov->errors and all status messages are in $prov->audit. Any time you want to inspect the status or error messages, you can dump those arrays. A handy way to do so is:

$prov->error(message=>'test breakpoint');

That will dump the contents of $prov->audit and $prov->errors and then terminate your program. If you want your program to continue after calling $prov->error, just set fatal=>0.

FUNCTIONS

new

Creates and returns a new Provision::Unix object.

As part of initialization, new() finds and reads in provision.conf from /[opt/usr]/local/etc, /etc, and the current working directory.

find_config

Searches in common etc directories for a named configuration file.

my $config = $self->find_config( file => 'provision.conf', debug=>0 );

error

Whenever a method runs into an unexpected condition, it should call $prov->error with a human intelligible error message. It should also specify whether the error is merely a warning or a fatal condition. Errors are considered fatal unless otherwise specified.

Examples:

$prov->error( message => 'could not write to file /etc/passwd' );

This error is fatal and will throw an exception, after dumping the contents of $prov->audit and $prov->errors to stderr.

A very helpful thing to do is call error with a location as well:

$prov->error( 
   message  => 'could not write to file /etc/passwd',
   location => join( ", ", caller ),
);

Doing so will tell you where the error message was encountered as well as what called the method. The latter is more likely where the error exists, making location a very beneficial thing to pass along.

audit

audit is a method that appends messages to the $prov->audit arrayref. It is primarily a convenience method for the programmer. Rather than spewing messages to stdout or stderr, they all get appended to an arrayref. They can then be inspected whenever desired. I expect to add additional support to that method for logging the messages to a file or SQL table.

AUTHOR

Matt Simerson, <matt at tnpi.net>

BUGS

Please report any bugs or feature requests to bug-unix-provision at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Provision-Unix. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Provision::Unix

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2008 Matt Simerson, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.