abusesa: Add abusesa::uploader

This commit is contained in:
Ossi Salmi 2016-07-08 12:14:48 +03:00
parent bf9889c5d8
commit bed546b956
2 changed files with 93 additions and 0 deletions

View file

@ -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,
}
}

View file

@ -0,0 +1,8 @@
{
<% if @room -%>
"room": "<%= @room %>",
<% end -%>
"authUrl": "<%= @authurl %>",
"boshUrl": "<%= @boshurl %>",
"rateLimit": <%= @ratelimit %>
}