From 3fc278dadb25024cb0dd5108066025a077008eff Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Tue, 12 Nov 2013 15:34:33 +0000 Subject: [PATCH] Update files part of fedocal configuration --- roles/fedocal/tasks/main.yml | 14 ++++- roles/fedocal/templates/alembic.ini | 51 +++++++++++++++++++ roles/fedocal/templates/fedocal-proxy.conf | 7 +++ roles/fedocal/templates/fedocal-reminder.cron | 7 +++ roles/fedocal/templates/fedocal.cfg | 34 +++++++++++++ roles/fedocal/templates/fedocal.conf | 23 +++++++++ roles/fedocal/templates/fedocal.wsgi | 22 ++++++++ roles/fedocal/templates/nuancier_admin.cfg | 44 ---------------- 8 files changed, 156 insertions(+), 46 deletions(-) create mode 100644 roles/fedocal/templates/alembic.ini create mode 100644 roles/fedocal/templates/fedocal-proxy.conf create mode 100644 roles/fedocal/templates/fedocal-reminder.cron create mode 100644 roles/fedocal/templates/fedocal.cfg create mode 100644 roles/fedocal/templates/fedocal.conf create mode 100644 roles/fedocal/templates/fedocal.wsgi delete mode 100644 roles/fedocal/templates/nuancier_admin.cfg diff --git a/roles/fedocal/tasks/main.yml b/roles/fedocal/tasks/main.yml index 6ad1efdbd1..621d2af206 100644 --- a/roles/fedocal/tasks/main.yml +++ b/roles/fedocal/tasks/main.yml @@ -22,7 +22,8 @@ dest={{ item.location }}/{{ item.dest }} owner=apache group=apache mode=0600 with_items: - - { file: fedocal_admin.cfg, location: /etc/fedocal, dest: fedocal.cfg } + - { file: fedocal.cfg, location: /etc/fedocal, dest: fedocal.cfg } + - { file: alembic.ini, location: /etc/fedocal, dest: alembic.ini } tags: - config notify: @@ -33,12 +34,13 @@ environment: FEDOCAL_CONFIG: /etc/fedocal/fedocal.cfg -- name: replace the fedocal configuration file by the one with the normal user +- name: Install all the configuration file of fedocal template: src={{ item.file }} dest={{ item.location }}/{{ item.file }} owner=apache group=apache mode=0600 with_items: - { file: fedocal.cfg, location: /etc/fedocal } + - { file: alembic.ini, location: /etc/fedocal } - { file: fedocal.conf, location: /etc/httpd/conf.d } - { file: fedocal.wsgi, location: /usr/share/fedocal } tags: @@ -46,6 +48,14 @@ notify: - restart apache +- name: Install the reminder cron job + template: src={{ item.file }} + dest={{ item.location }}/{{ item.file }} + with_items: + - { file: 'fedocal-reminder.cron', location: /etc/cron.d } + tags: + - config + - name: set sebooleans so fedocal can talk to the db action: seboolean name=httpd_can_network_connect_db state=true diff --git a/roles/fedocal/templates/alembic.ini b/roles/fedocal/templates/alembic.ini new file mode 100644 index 0000000000..4260a6d0ce --- /dev/null +++ b/roles/fedocal/templates/alembic.ini @@ -0,0 +1,51 @@ +# A generic, single database configuration. + +[alembic] +# path to migration scripts +script_location = /usr/share/fedocal/alembic + +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + +#sqlalchemy.url = postgresql://<%= fedocal_app %>:<%= fedocal_appPassword %>@db-fedocal/fedocal +sqlalchemy.url = postgresql://{{ fedocal_db_user }}:{{ fedocal_db_pass }}@{{ fedocal_db_host }}/{{ nuancier_db_name }} + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/roles/fedocal/templates/fedocal-proxy.conf b/roles/fedocal/templates/fedocal-proxy.conf new file mode 100644 index 0000000000..08b7e6d4a2 --- /dev/null +++ b/roles/fedocal/templates/fedocal-proxy.conf @@ -0,0 +1,7 @@ +RewriteEngine On + +ProxyPass <%= path %> <%= proxyurl %>/calendar +ProxyPassReverse <%= path %> <%= proxyurl %>/calendar + +RequestHeader set X-Forwarded-Scheme https early + diff --git a/roles/fedocal/templates/fedocal-reminder.cron b/roles/fedocal/templates/fedocal-reminder.cron new file mode 100644 index 0000000000..a224ed3548 --- /dev/null +++ b/roles/fedocal/templates/fedocal-reminder.cron @@ -0,0 +1,7 @@ +# Sends the reminder about coming meetings +# +# The frequency set here should be consistent with the one set in the +# configuration file. +# +*/30 * * * * root FEDOCAL_CONFIG=/etc/fedocal/fedocal.cfg /usr/bin/fedocal_cron.py + diff --git a/roles/fedocal/templates/fedocal.cfg b/roles/fedocal/templates/fedocal.cfg new file mode 100644 index 0000000000..5f54a0160f --- /dev/null +++ b/roles/fedocal/templates/fedocal.cfg @@ -0,0 +1,34 @@ +# Beware that the quotes around the values are mandatory + +### Secret key for the Flask application +SECRET_KEY='{{ fedocal_secret_key }}' + +### url to the database server: +#DB_URL=mysql://user:pass@host/db_name +#DB_URL=postgres://user:pass@host/db_name +#DB_URL="postgresql://<%= fedocal_app %>:<%= fedocal_appPassword %>@db-fedocal/fedocal" +DB_URL='postgresql://{{ fedocal_db_user }}:{{ fedocal_db_pass }}@{{ fedocal_db_host }}/{{ nuancier_db_name }}' + + +### The FAS group in which the admin of fedocal are +ADMIN_GROUP='sysadmin-calendar' + +### The address of the SMTP server used to send the reminders emails +### via the cron job. +### Default: 'localhost' +SMTP_SERVER='localhost' + +### The cron job can be set with any frequency but fedocal_cron needs +### this information to accurately retrieve the meetings to remind and +### avoid sending multiple reminders for a single meeting. +### Default: 30 +CRON_FREQUENCY=30 + +### Path to the alembic configuration file +### When creating the database, we need to tell the database which +### revision of alembic we are at and to do this we need access to the +### alembic.ini file. +PATH_ALEMBIC_INI='/etc/fedocal/alembic.ini' + +# This is required to fix login +PREFERRED_URL_SCHEME='https' diff --git a/roles/fedocal/templates/fedocal.conf b/roles/fedocal/templates/fedocal.conf new file mode 100644 index 0000000000..27d3279b2b --- /dev/null +++ b/roles/fedocal/templates/fedocal.conf @@ -0,0 +1,23 @@ + +Alias /calendar/static /usr/lib/python2.6/site-packages/fedocal/static/default/ + +WSGIDaemonProcess fedocal user=apache maximum-requests=1000 display-name=fedocal processes=2 threads=1 +WSGISocketPrefix run/wsgi +WSGIRestrictStdout On +WSGIRestrictSignal Off +WSGIPythonOptimize 1 + +WSGIScriptAlias /calendar /usr/share/fedocal/fedocal.wsgi + + + WSGIProcessGroup fedocal + + # Apache 2.4 + Require all granted + + + # Apache 2.2 + Order deny,allow + Allow from all + + diff --git a/roles/fedocal/templates/fedocal.wsgi b/roles/fedocal/templates/fedocal.wsgi new file mode 100644 index 0000000000..a73b24b76c --- /dev/null +++ b/roles/fedocal/templates/fedocal.wsgi @@ -0,0 +1,22 @@ +#-*- 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__ = ['SQLAlchemy >= 0.7', 'jinja2 >= 2.4'] +import pkg_resources + +import os +## Set the environment variable pointing to the configuration file +os.environ['FEDOCAL_CONFIG'] = '/etc/fedocal/fedocal.cfg' + +## The following is only needed if you did not install fedocal +## as a python module (for example if you run it from a git clone). +#import sys +#sys.path.insert(0, '/path/to/fedocal/') + + +## The most import line to make the wsgi working +from fedocal import APP as application + diff --git a/roles/fedocal/templates/nuancier_admin.cfg b/roles/fedocal/templates/nuancier_admin.cfg deleted file mode 100644 index 95288741ec..0000000000 --- a/roles/fedocal/templates/nuancier_admin.cfg +++ /dev/null @@ -1,44 +0,0 @@ -# Beware that the quotes around the values are mandatory - -import os - -### Secret key for the Flask application -SECRET_KEY='{{ nuancier_secret_key }}' - -### url to the database server: -DB_URL='postgresql://{{ nuancier_db_admin_user }}:{{ nuancier_db_admin_pass }}@{{ nuancier_db_host }}/{{ nuancier_db_name }}' - -### The FAS groups in which the admin of nuancier-lite are -### This can either be a single group or multiple, defined between -### parenthesis. -ADMIN_GROUP=('sysadmin-nuancier', 'sysadmin-main') - - -### Static folder -### The folder containing the css, javascript as well as the pictures -### candidates and the cache of those pictures. -### This directory should be somewhere where apache can access, it's -### proposed in '/var/www/nuancier' -STATIC_FOLDER = '/var/www/nuancier' - -### Pictures folder -### The folder in which are located the pictures of the different elections. -### This folder does not have to be writable by the application but should be -### readable. -### /!\ It should be the full path to this folder -PICTURE_FOLDER = os.path.join(STATIC_FOLDER, 'pictures') - -### Cache folder -### The folder in which the application will generate thumbnails of the pictures -### selected for an election. -### This folder *must* be *writable* by the application. -### /!\ It should be the full path to this folder -CACHE_FOLDER = os.path.join(STATIC_FOLDER, 'cache') - -### Size of the thumbnails (keeping the ratio) -### In order to reduce the loading page of the election page that might contains -### more than hundreds pictures, the application generates thumbnails of each -### pictures. -### The application will keep the ratio intact and just make sure that either -### length or width of the picture fit the length and width specified below. -THUMB_SIZE = (256, 256)