From 21158668680343fce0a161efa6ffe3d0e8c77f4b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Fri, 20 Sep 2013 12:01:18 +0200 Subject: [PATCH] Update the nuancier role and add a new template --- roles/nuancier/tasks/main.yml | 34 ++++++++++++++-- roles/nuancier/templates/nuancier_admin.cfg | 44 +++++++++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 roles/nuancier/templates/nuancier_admin.cfg diff --git a/roles/nuancier/tasks/main.yml b/roles/nuancier/tasks/main.yml index 5c2ba04c1c..012d98e9c0 100644 --- a/roles/nuancier/tasks/main.yml +++ b/roles/nuancier/tasks/main.yml @@ -10,13 +10,39 @@ - name: copy sundry nuancier configuration template: > - src={{ item.file }} dest={{ item.location }}/{{ item.file }} + src={{ item.file }} dest={{ item.location }}/{{ item.dest }} owner=apache group=apache mode=0600 with_items: - - { file: nuancier.cfg, location: /etc/nuancier } - - { file: nuancier.conf, location: /etc/httpd/conf.d } - - { file: nuancier.wsgi, location: /usr/share/nuancier } + - { file: nuancier_admin.cfg, location: /etc/nuancier, dest:nuancier.cfg } + - { file: nuancier.conf, location: /etc/httpd/conf.d, dest: nuancier.conf } + - { file: nuancier.wsgi, location: /usr/share/nuancier, dest: nuancier.wsgi } tags: - config notify: - restart apache + +- name: create pictures folder where we upload the pictures + action: file state=directory path=/var/www/nuancier/pictures + tags: + - setup + +- name: create the cache folder where nuancier creates the thumbnails + action: file state=directory path=/var/www/nuancier/cache + owner=apache group=apache + tags: + - setup + +- name: create the database scheme + command: NUANCIER_CONFIG=/etc/nuancier/nuancier.cfg /usr/share/nuancier/nuancier-lite_createdb.py + +- name: replace the nuancier configuration file by the one with the normal user + template: > + src={{ item.file }} dest={{ item.location }}/{{ item.dest }} + owner=apache group=apache mode=0600 + with_items: + - { file: nuancier.cfg, location: /etc/nuancier, dest:nuancier.cfg } + tags: + - config + notify: + - restart apache + diff --git a/roles/nuancier/templates/nuancier_admin.cfg b/roles/nuancier/templates/nuancier_admin.cfg new file mode 100644 index 0000000000..42e094c4cb --- /dev/null +++ b/roles/nuancier/templates/nuancier_admin.cfg @@ -0,0 +1,44 @@ +# 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='postgres://{{ 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)