# Install AbuseSA.
#
class abusesa {

    case $::operatingsystem {
        "centos","redhat": {
            case $::operatingsystemrelease {
                /^5/: {
                    package { "python26":
                        ensure => installed,
                    }
                    Python::Setup::Install["/usr/local/src/abusesa"] {
                        python  => "python2.6",
                        require => Package["python26"],
                    }
                }
            }
        }
    }

    if !$abusesa_package {
        if $abusesa_package_latest {
            $abusesa_package = $abusesa_package_latest
        } else {
            fail("Must define \$abusesa_package or \$abusesa_package_latest")
        }
    }

    file { "/usr/local/src/abusesa.tar.gz":
        ensure => present,
        mode   => "0644",
        owner  => "root",
        group  => $::operatingsystem ? {
            "openbsd" => "wheel",
            default   => "root",
        },
        source => "puppet:///files/packages/${abusesa_package}",
    }
    util::extract::tar { "/usr/local/src/abusesa":
        ensure  => latest,
        strip   => 1,
        source  => "/usr/local/src/abusesa.tar.gz",
        require => File["/usr/local/src/abusesa.tar.gz"],
        before  => Python::Setup::Install["/usr/local/src/abusesa"],
    }
    python::setup::install { "/usr/local/src/abusesa": }

}
