diff --git a/abusesa/manifests/uploader.pp b/abusesa/manifests/uploader.pp new file mode 100644 index 0000000..7918629 --- /dev/null +++ b/abusesa/manifests/uploader.pp @@ -0,0 +1,85 @@ +# Install AbuseSA Uploader. +# +# === Parameters +# +# $authurl: +# Authentication path. Defaults to '/collab/?action=authcredentials'. +# +# $boshurl: +# XMPP BOSH path. Defaults to '/bosh/'. +# +# $room: +# Default destination room. +# +# $webhosts: +# List of uploader virtual hosts. +# +class abusesa::uploader( + $authurl='/collab/?action=authcredentials', + $boshurl='/bosh/', + $room=undef, + $webhosts=undef, + $ratelimit='10', +) { + + if ! $abusesa_uploader_package { + if $::abusesa_uploader_package_latest { + $abusesa_uploader_package = $::abusesa_uploader_package_latest + } else { + fail('Must define $abusesa_uploader_package or $abusesa_uploader_package_latest') + } + } + + python::pip::install { 'abusesa-uploader.tar.gz': + source => "puppet:///files/packages/${abusesa_uploader_package}", + } + + $htdocs = $::operatingsystem ? { + 'ubuntu' => '/usr/local/share/abusesa-uploader/htdocs', + default => '/usr/share/abusesa-uploader/htdocs', + } + + file { "${htdocs}/config.json": + ensure => present, + mode => '0644', + owner => 'root', + group => 'root', + content => template('abusesa/uploader/config.json.erb'), + require => Python::Pip::Install['abusesa-uploader.tar.gz'], + } + + file { "${htdocs}/.htaccess": + ensure => $webhosts ? { + undef => present, + default => absent, + }, + mode => '0644', + owner => 'root', + group => 'root', + content => "RewriteEngine Off\n", + require => Python::Pip::Install['abusesa-uploader.tar.gz'], + } + + if $webhosts { + abusesa::uploader::configwebhost { $webhosts: + htdocs => $htdocs, + } + } + +} + + +# Enable AbuseSA Uploader for virtual host. +# +define abusesa::uploader::configwebhost($htdocs) { + + if ! defined(Abusesa::Configwebhost[$name]) { + abusesa::configwebhost { $name: } + } + + file { "/srv/www/https/${name}/abusesa/uploader": + ensure => link, + target => $htdocs, + } + +} diff --git a/abusesa/templates/uploader/config.json.erb b/abusesa/templates/uploader/config.json.erb new file mode 100644 index 0000000..ee41daf --- /dev/null +++ b/abusesa/templates/uploader/config.json.erb @@ -0,0 +1,8 @@ +{ +<% if @room -%> + "room": "<%= @room %>", +<% end -%> + "authUrl": "<%= @authurl %>", + "boshUrl": "<%= @boshurl %>", + "rateLimit": <%= @ratelimit %> +}