diff --git a/playbooks/groups/badges-web.yml b/playbooks/groups/badges-web.yml index e36120b652..6c98e148f5 100644 --- a/playbooks/groups/badges-web.yml +++ b/playbooks/groups/badges-web.yml @@ -24,6 +24,9 @@ user: root gather_facts: True + roles: + - /srv/web/infra/ansible/roles/badges-frontend + vars_files: - /srv/web/infra/ansible/vars/global.yml - ${private}/vars.yml diff --git a/roles/badges-frontend/files/tahrir.conf b/roles/badges-frontend/files/tahrir.conf new file mode 100644 index 0000000000..5f4cd358ea --- /dev/null +++ b/roles/badges-frontend/files/tahrir.conf @@ -0,0 +1,14 @@ +Alias /static /usr/share/tahrir/static + +WSGIDaemonProcess tahrir user=tahrir group=tahrir maximum-requests=1000 display-name=tahrir processes=4 threads=4 +WSGISocketPrefix run/wsgi +WSGIRestrictStdout On +WSGIRestrictSignal Off +WSGIPythonOptimize 1 + +WSGIScriptAlias / /usr/share/tahrir/tahrir.wsgi + + + WSGIProcessGroup tahrir + + diff --git a/roles/badges-frontend/files/tahrir.wsgi b/roles/badges-frontend/files/tahrir.wsgi new file mode 100644 index 0000000000..493b130ed8 --- /dev/null +++ b/roles/badges-frontend/files/tahrir.wsgi @@ -0,0 +1,15 @@ +import sys +sys.stdout = sys.stderr + +import __main__ +__main__.__requires__ = __requires__ = 'tahrir' +import pkg_resources +pkg_resources.require(__requires__) + +import os +os.environ['PYTHON_EGG_CACHE'] = '/var/www/.python-eggs' + +from pyramid.paster import get_app, setup_logging +ini_path = '/etc/tahrir/tahrir.ini' +setup_logging(ini_path) +application = get_app(ini_path, 'main') diff --git a/roles/badges-frontend/tasks/main.yml b/roles/badges-frontend/tasks/main.yml new file mode 100644 index 0000000000..b2d10ef1e1 --- /dev/null +++ b/roles/badges-frontend/tasks/main.yml @@ -0,0 +1,63 @@ +--- +# Configuration for the tahrir webapp + +- name: install needed packages + yum: pkg=$item state=installed + with_items: + - python-tahrir + - python-psycopg2 + tags: + - packages + +- name: copy tahrir app configuration + template: > + src=$item dest=/etc/tahrir/$item + owner=apache group=apache mode=0600 + with_items: + - tahrir.ini + tags: + - config + notify: + - restart apache + +- name: copy tahrir wsgi script + copy: > + src=$item dest=/usr/share/tahrir/$item + owner=apache group=apache mode=0644 + with_items: + - tahrir.wsgi + tags: + - config + notify: + - restart apache + +- name: copy tahrir httpd config + copy: > + src=$item dest=/etc/httpd/conf.d/$item + owner=apache group=apache mode=0644 + with_items: + - tahrir.conf + tags: + - config + notify: + - restart apache + +- name: make badge png directory + file: > + path=/usr/share/badges/pngs + state=directory + owner=apache group=apache mode=0755 + tags: + - config + - assets + +- name: copy over all our badge images + copy: > + src=$item + dest=/usr/share/badges/pngs/ + owner=apache group=apache mode=0644 + with_fileglob: + - /srv/web/infra/badges/pngs/*.png + tags: + - config + - assets diff --git a/roles/badges-frontend/templates/tahrir.ini b/roles/badges-frontend/templates/tahrir.ini new file mode 100644 index 0000000000..be7c7f88db --- /dev/null +++ b/roles/badges-frontend/templates/tahrir.ini @@ -0,0 +1,76 @@ +[server:main] +use = egg:pyramid#wsgiref +host = localhost +port = 80 + +[pipeline:main] +pipeline = + pyramid + +[app:pyramid] + +use = egg:tahrir + +#pyramid.reload_templates = true +pyramid.default_locale_name = en +pyramid.includes = + pyramid_tm + +sqlalchemy.url = postgresql://${tahrirDBUser}:${tahrirDBPassword}@db-tahrir/tahri + +mako.directories=tahrir:templates + +tahrir.admin = ralph +tahrir.pngs.uri = /usr/share/tahrir/pngs + +{% if env == 'staging' %} +tahrir.title = Fedora Badges (staging!) +tahrir.base_url = badges.stg.fedoraproject.org +tahrir.openid_identifier = https://id.stg.fedoraproject.org +{% else %} +tahrir.title = Fedora Badges +tahrir.base_url = badges.fedoraproject.org +tahrir.openid_identifier = https://id.fedoraproject.org +{% endif %} + +session.secret="${tahrirSessionSecret}" + + +# Begin logging configuration + +[loggers] +keys = root, tahrir, sqlalchemy + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[logger_tahrir] +level = DEBUG +handlers = +qualname = tahrir + +[logger_sqlalchemy] +level = INFO +handlers = +qualname = sqlalchemy.engine +# "level = INFO" logs SQL queries. +# "level = DEBUG" logs SQL queries and results. +# "level = WARN" logs neither. (Recommended for production systems.) + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s + +# End logging configuration