First draft of a statscache/frontend role.

This commit is contained in:
Ralph Bean 2015-11-01 21:05:59 +00:00
parent d23d249652
commit 7710c5d15b
6 changed files with 139 additions and 1 deletions

View file

@ -47,7 +47,7 @@
- apache
- role: openvpn/client
when: env != "staging"
# TODO -- include statscache/frontend here
- statscache/frontend
tasks:
- include: "{{ tasks }}/mod_wsgi.yml"

View file

@ -0,0 +1,8 @@
# http://stackoverflow.com/questions/8007176/500-error-without-anything-in-the-apache-logs
import logging
import sys
logging.basicConfig(stream=sys.stderr)
import statscache.app
application = statscache.app.app
#application.debug = True # Nope. Be careful!

View file

@ -0,0 +1,74 @@
---
# Configuration for the Fedora Notifications webapp
- name: install needed packages
yum: pkg={{ item }} state=present
with_items:
- statscache-web
- python-psycopg2
- libsemanage-python
notify:
- restart apache
tags:
- statscache
- statscache/frontend
- name: copy statscache app configuration
template: >
src={{ item }} dest=/etc/fedmsg.d/{{ item }}
owner=apache group=apache mode=0600
with_items:
- statscache.py
notify:
- restart apache
tags:
- statscache
- statscache/frontend
- name: copy statscache httpd config
template: >
src=statscache.conf dest=/etc/httpd/conf.d/statscache.conf
owner=apache group=apache mode=0644
notify:
- restart apache
tags:
- statscache
- statscache/frontend
- name: copy custom wsgi file
copy: src=statscache.wsgi dest=/usr/share/statscache/apache/statscache.wsgi mode=0644
notify:
- restart apache
tags:
- statscache
- statscache/frontend
- name: copy app configuration
template: >
src=statscache.cfg dest=/etc/statscache.cfg
owner=root group=apache mode=0640
notify:
- restart apache
tags:
- statscache
- statscache/frontend
- name: apply selinux type to static files
file: >
dest=/usr/share/statscache/static
setype=httpd_sys_content_t
state=directory
recurse=yes
tags:
- statscache
- statscache/frontend
- selinux
- name: ensure selinux lets httpd talk to postgres
seboolean: name={{item}} state=yes persistent=yes
with_items:
- httpd_can_network_connect_db
tags:
- statscache
- statscache/frontend
- selinux

View file

@ -0,0 +1,2 @@
### Secret key for the Flask application
SECRET_KEY='{{statscache_secret_key}}'

View file

@ -0,0 +1,17 @@
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonEggs /var/cache/statscache/.python-eggs
WSGIDaemonProcess statscache user=apache group=apache maximum-requests=50000 display-name=statscache processes=4 threads=4 inactivity-timeout=300
WSGISocketPrefix run/wsgi
WSGIRestrictStdout Off
WSGIRestrictSignal Off
WSGIPythonOptimize 1
WSGIScriptAlias / /usr/share/statscache/apache/statscache.wsgi
Alias /static/ /usr/lib/python2.7/site-packages/statscache/static/
<Directory /usr/share/statscache/>
Order deny,allow
Allow from all
</Directory>

View file

@ -0,0 +1,37 @@
import datetime
config = {
"statscache.datagrepper.profile": False,
# Consumer stuff
"statscache.consumer.enabled": False,
"statscache.sqlalchemy.uri": "postgres://statscache:{{statscache_db_password}}@db01/statscache",
# stats models will go back at least this far (current value arbitrary)
"statscache.consumer.epoch": datetime.datetime(year=2015, month=8, day=8),
# stats models are updated at this frequency
"statscache.producer.frequency": datetime.timedelta(seconds=1),
# Configuration of web API
"statscache.app.maximum_rows_per_page": 100,
"statscache.app.default_rows_per_page": 100,
# Turn on logging for statscache
"logging": dict(
loggers=dict(
statscache={
"level": "DEBUG",
"propagate": False,
"handlers": ["console"],
},
statscache_plugins={
"level": "DEBUG",
"propagate": False,
"handlers": ["console"],
},
),
),
}