From f5de255fd3b8387ed1c29600e29bfce561a7ce1d Mon Sep 17 00:00:00 2001 From: Chaoyi Zha Date: Wed, 10 Jun 2015 00:21:49 +0000 Subject: [PATCH] Set up mote webapp role --- roles/mote/tasks/main.yml | 72 +++++++++++++++++++++++++++++ roles/mote/templates/mote.conf | 24 ++++++++++ roles/mote/templates/mote.wsgi | 24 ++++++++++ roles/mote/templates/mote_config.py | 39 ++++++++++++++++ 4 files changed, 159 insertions(+) create mode 100644 roles/mote/tasks/main.yml create mode 100644 roles/mote/templates/mote.conf create mode 100644 roles/mote/templates/mote.wsgi create mode 100644 roles/mote/templates/mote_config.py diff --git a/roles/mote/tasks/main.yml b/roles/mote/tasks/main.yml new file mode 100644 index 0000000000..3a01c81750 --- /dev/null +++ b/roles/mote/tasks/main.yml @@ -0,0 +1,72 @@ +--- +# Configuration for the mote webapp + +- name: install needed packages + yum: pkg={{ item }} state=present + with_items: + - mote + tags: + - packages + +- name: copy sundry mote configuration + template: src={{ item.file }} + dest={{ item.location }}/{{ item.dest }} + owner=apache group=apache mode=0600 + with_items: + - { file: mote_config.py, location: /etc/mote, dest: config.py } + - { file: alembic.ini, location: /etc/nuancier, dest: alembic.ini } + changed_when: "1 != 1" + tags: + - config + notify: + - restart apache + +- name: create the cache folder where nuancier creates the thumbnails + action: file state=directory + path=/var/cache/nuancier/cache + owner=apache group=apache mode=0700 + tags: + - setup + +- name: replace the mote configuration file by the one with the normal user + template: src={{ item.file }} + dest="{{ item.location }}/{{ item.file }}" + owner=apache group=apache mode=0600 + changed_when: "1 != 1" + with_items: + - { file: mote_config.py, location: /etc/mote, dest: config.py } + - { file: mote.conf, location: /etc/httpd/conf.d } + - { file: mote.wsgi, location: /usr/share/mote } + tags: + - config + notify: + - restart apache + - restart memcached + +- name: set sebooleans so nuancier can talk to the db + action: seboolean name=httpd_can_network_connect_db + state=true + persistent=true + +- name: apply selinux type to static files + file: > + dest=/usr/lib/python2.7/site-packages/mote/static/ + setype=httpd_sys_content_t + state=directory + recurse=yes +- name: apply selinux type to meetbot files + file: > + dest=/srv/web/meetbot/ + setype=httpd_sys_content_t + state=directory + recurse=yes + +- name: set sebooleans so apache can use memcached + action: seboolean name=httpd_can_network_memcache + state=true + persistent=true + +- name: apply selinux type to the wsgi file + file: > + dest=/usr/share/mote/mote.wsgi + setype=httpd_sys_content_t diff --git a/roles/mote/templates/mote.conf b/roles/mote/templates/mote.conf new file mode 100644 index 0000000000..0b42cef0a0 --- /dev/null +++ b/roles/mote/templates/mote.conf @@ -0,0 +1,24 @@ +# Apache configuration file for mote + +Alias /static /usr/lib/python2.7/site-packages/mote/static + +WSGIDaemonProcess mote user=apache maximum-requests=1000 display-name=mote processes=2 threads=1 +WSGISocketPrefix run/wsgi +WSGIRestrictStdout On +WSGIRestrictSignal Off +WSGIPythonOptimize 1 + +WSGIScriptAlias / /usr/share/mote/mote.wsgi + + + WSGIProcessGroup mote + + # Apache 2.4 + Require all granted + + + # Apache 2.2 + Order deny,allow + Allow from all + + diff --git a/roles/mote/templates/mote.wsgi b/roles/mote/templates/mote.wsgi new file mode 100644 index 0000000000..7348e61a7e --- /dev/null +++ b/roles/mote/templates/mote.wsgi @@ -0,0 +1,24 @@ +#-*- coding: utf-8 -*- + +# The three lines below are required to run on EL6 as EL6 has +# two possible version of python-sqlalchemy and python-jinja2 +# These lines make sure the application uses the correct version. +import __main__ +__main__.__requires__ = ['jinja2 >= 2.4'] +import pkg_resources + +import os +#Set the environment variable pointing to the configuration file +os.environ['MOTE_CONFIG_FOLDER'] = '/etc/mote/' + +# The following is only needed if you did not install mote +# as a python module (for example if you run it from a git clone). +# import sys +# sys.path.insert(0, '/path/to/mote/') + + +# The most import line to make the wsgi working +from mote import app as application +from mote import soke +# Generate cache and store in memcached +soke.run() diff --git a/roles/mote/templates/mote_config.py b/roles/mote/templates/mote_config.py new file mode 100644 index 0000000000..8af7c72170 --- /dev/null +++ b/roles/mote/templates/mote_config.py @@ -0,0 +1,39 @@ +''' +Crawler Configuration +''' + +log_endpoint = "/srv/web/meetbot" +#log_endpoint = "/home/user/mote/test_data/meetbot" + +# Fedora has a "teams" folder which contains +# logs from meetings started with a certain team name +# for instance, `#startmeeting famna` will save in "/teams/famna" +# Folders not in "teams" reflect the channel name of the meeting +log_team_folder = "teams" + +# Directories to ignore in crawling the logs. +# These folders are ignored. The "meetbot" folder is +# an infinite loop on Fedora's meetbot instance. +ignore_dir = "meetbot" + +# Location where raw logs/minutes are stored (remote location) +meetbot_prefix = "http://meetbot.fedoraproject.org" + +# Time (in seconds) after which the log/meeting cache expires +cache_expire_time = 60 * 60 * 1 + + +''' +Development Configuration +''' + +enable_debug = True +app_port = 5000 + +''' +General Configuration +''' + +app_host = "127.0.0.1" +admin_groups = ["sysadmin-mote"] +memcached_ip = "127.0.0.1:11211"