Add support for installing ARA wsgi middleware for sqlite databases

ARA is going to bundle a WSGI middleware that allows an operator
to route an URL (by default ^.*/ara-report) to the ARA web application.
This URL is expected to contain an 'ansible.sqlite' database that
would have been uploaded as part of log collection.

There are no static files generated as part of this process. The
web application reads directly from the database. It is meant
to avoid having to generate a static report for each job which does
not scale very well for the amount of jobs we are running.

For more details, see this code review in ARA [1].

[1]: https://review.openstack.org/#/c/511992/

Change-Id: I3b10c93b4902a9b45e23c227863e472697f662ef
This commit is contained in:
David Moreau-Simard 2017-10-20 18:24:25 -04:00 committed by David Moreau Simard
parent 8c0380f50f
commit 5c14e86d37
No known key found for this signature in database
GPG Key ID: 33A07694CBB71ECC
4 changed files with 45 additions and 2 deletions

View File

@ -1,11 +1,11 @@
# See parameter documetation inside ../manifests/single_node_ci.pp
# Fields commented out have reasonable default values
domain: your-domain.example.com
jenkins_ssh_public_key: your-jenkins-public-key-no-whitespace
jenkins_ssh_public_key: your-jenkins-public-key-no-whitespace
ara_middleware: false
#swift_authurl:
#swift_user:
#swift_key:
#swift_tenant_name:
#swift_region_name:
#swift_default_container:

View File

@ -23,6 +23,7 @@ node default {
class { '::openstackci::logserver':
domain => hiera('domain'),
jenkins_ssh_key => hiera('jenkins_ssh_public_key'),
ara_middleware => hiera('ara_middleware', false),
swift_authurl => hiera('swift_authurl', ''),
swift_user => hiera('swift_user', ''),
swift_key => hiera('swift_key', ''),

View File

@ -13,11 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# [*ara_middleware*]
# (optional) Whether or not to set up the ARA database middleware
# Defaults to false.
#
# == Class: openstackci::logserver
#
class openstackci::logserver (
$domain,
$jenkins_ssh_key,
$ara_middleware = false,
$ara_middleware_tmpdir_max_age = 3600,
$ara_middleware_database_directory = 'ara-report',
$swift_authurl = '',
$swift_user = '',
$swift_key = '',
@ -196,4 +203,17 @@ class openstackci::logserver (
require => File['/usr/local/sbin/log_archive_maintenance.sh'],
}
if $ara_middleware {
package { 'ara':
ensure => 'latest',
provider => 'openstack_pip',
require => [
Package['build-essential'],
Package['python-dev'],
Package['libffi-dev'],
Package['libssl-dev']
],
notify => Service['httpd']
}
}
}

View File

@ -60,6 +60,28 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %>
<% end -%>
RewriteEngine On
<% if @ara_middleware -%>
<Directory "/usr/local/bin">
<Files "ara-wsgi-sqlite">
Allow from all
Satisfy Any
</Files>
</Directory>
# Redirect .*/<%= @ara_middleware_database_directory %> to the ARA sqlite wsgi middleware
# This middleware automatically loads the ARA web application with the
# database located at .*/<%= @ara_middleware_database_directory %>/ansible.sqlite.
SetEnv ARA_WSGI_TMPDIR_MAX_AGE <%= @ara_middleware_tmpdir_max_age %>
SetEnv ARA_WSGI_LOG_ROOT <%= @docroot %>
SetEnv ARA_WSGI_DATABASE_DIRECTORY <%= @ara_middleware_database_directory %>
WSGIScriptAliasMatch ^.*/<%= @ara_middleware_database_directory %> /usr/local/bin/ara-wsgi-sqlite
# Everything beyond this point is rewritten to htmlify.
# Make sure we don't do that for dynamic ARA reports.
RewriteCond %{REQUEST_URI} ^.*/<%= @ara_middleware_database_directory %> [NC]
RewriteRule .* - [L]
<% end -%>
# If the specified file does not exist, look if there is a gzipped version
# If there is, serve that one instead
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f