h1. NAME

Csistck - Perl system consistency check framework

h1. SYNOPSIS

<pre>
    use Csistck;
    
    for my $host (qw/a b/) {
        host $host => role('test');
    }

    host 'c' => role('test');
    
    role 'test' => 
        template(".files/test.tt", "/tmp/test", { text => "Some text here" }),
        permission("/tmp/test*", mode => '0777', uid => 100, gid => 100);
    
    check;
</pre>

The script can then be called directly, using command line arguements below

h1. DESCRIPTION

Csistck is a small Perl framework for writing scripts to maintain system configuration and consistency. The focus of csistck is to stay lightweight, simple, and flexible.

h1. EXTENDING ROLES

Roles can be defined using the @role@ keyword syntax, however a more flexible method is to extend a new object from Csistck::Role:

<pre>
    use Csistck;
    use base 'Csistck::Role';

    sub defaults {
        my $self = shift;
        $self->{config} = '/etc/example.conf';
    }

    sub tests {
        my $self = shift;
        $self->add(pkg({
            dpkg => 'test-server',
            pkg_info => 'net-test'
        }),
        template('files/example.conf', $self->{config}, { example => $self });
    }

    1;
</pre>

See Csistck::Role for information on extending roles

h1. METHODS

h2. option($name, $value)

Set option to specified value.

h3. Available Options

* pkg_type [string]
Set package type

* domain_name [string]
Set default domain name to append to hosts


h2. host($hostname, [@tests]);

Append test or array of tests to host definition.

<pre>
    host 'hostname' => noop(1), noop(1);
    host 'hostname' => noop(0);
</pre>

Returns a reference to the host object.

h2. role($rolename, [@tests]);

Append test or array of tests to role definition.

<pre>
    role 'test' => noop(0);
    host 'hostname' => role('test');
</pre>

Returns a reference to the role object.

h2. noop($return)

"No operation" test, used only for testing or placeholders.

<pre>
    role 'test' => noop(1);
</pre>

h2. file($glob, $target)

Copy files matching file glob pattern to target directory.

<pre>
    role 'test' => file("lighttpd/app/*.conf", "/etc/lighttpd");
</pre>

See Csistck::Test::File

h2. template($template, $target, [%args])

Process file $template as a Template Toolkit template, output to path $target. Hashref %args is passed to the template processor.

<pre>
    role 'test' => template("sys/motd", "/etc/motd", { hot => 'dog' });
</pre>

See Csistck::Test::Template

h2. permission($glob, %args)

Change permissions on files matching file glob pattern

<pre>
    role 'test' => permission("/etc/couchdb/*", {
        mode => '0640',
        uid => 130,
        gid => 130
    });
</pre>

See Csistck::Test::Permission

h2. script($script, [@arguments])

Call script with specified arguments

<pre>
    role 'test' => script("apache2/mod-check", "rewrite");
</pre>

See Csistck::Test::Script

h2. pkg($package, [$type])

Check for package using system package manager. The @package@ argument may be specified as a string, or as a hashref to specify package names for multiple package managers. The package manager will be automatically detected if no package manager is specified.

<pre>
    option 'pkg_type' => 'dpkg';
    role 'test' => 
        pkg("lighttpd", 'dpkg'),
        pkg({
            dpkg => 'snmp-server',
            pkg_info => 'net-snmp'
        });
</pre>

See Csistck::Test::Pkg for more information

h1. SCRIPT USAGE

Scripts based on csistck will run in an interactive mode by default. The following command line options are recognized in a csistck based script

* *--[no]repair*
Automate repair mode, do not run in interactive mode.

* *--[no]verbose*
Toggle verbose reporting of events

* *--[no]debug*
Toggle debug reporting of events

* *--[no]quiet*
Toggle event reporting of errors


h1. AUTHOR

Anthony Johnson, @<aj@ohess.org>@

h1. COPYRIGHT AND LICENSE

Copyright (c) 2011 Anthony Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

