From c5e7536b4b79429daecad417b6b70a18e84ea132 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mon, 29 Sep 2014 10:26:52 +0200 Subject: [PATCH] Get started on the anitya roles for frontend and backend --- roles/anitya/backend/tasks/main.yml | 41 +++++++++++++++++++ roles/anitya/backend/templates/anitya.cfg | 26 ++++++++++++ .../anitya/backend/templates/anitya_admin.cfg | 26 ++++++++++++ roles/anitya/frontend/tasks/main.yml | 37 +++++++++++++++++ roles/anitya/frontend/templates/anitya.cfg | 26 ++++++++++++ roles/anitya/frontend/templates/anitya.conf | 23 +++++++++++ roles/anitya/frontend/templates/anitya.wsgi | 22 ++++++++++ 7 files changed, 201 insertions(+) create mode 100644 roles/anitya/backend/tasks/main.yml create mode 100644 roles/anitya/backend/templates/anitya.cfg create mode 100644 roles/anitya/backend/templates/anitya_admin.cfg create mode 100644 roles/anitya/frontend/tasks/main.yml create mode 100644 roles/anitya/frontend/templates/anitya.cfg create mode 100644 roles/anitya/frontend/templates/anitya.conf create mode 100644 roles/anitya/frontend/templates/anitya.wsgi diff --git a/roles/anitya/backend/tasks/main.yml b/roles/anitya/backend/tasks/main.yml new file mode 100644 index 0000000000..f1b9fb8193 --- /dev/null +++ b/roles/anitya/backend/tasks/main.yml @@ -0,0 +1,41 @@ +--- +# Configuration for the anitya webapp + +- name: clean yum metadata + command: yum clean all + tags: + - packages + +- name: install needed packages + yum: pkg={{ item }} state=installed + with_items: + - anitya + - python-psycopg2 + - libsemanage-python + tags: + - packages + +- name: copy sundry anitya configuration + template: src={{ item.file }} + dest={{ item.location }}/{{ item.dest }} + owner=root group=root mode=0600 + with_items: + - { file: anitya_admin.cfg, location: /etc/anitya, dest: anitya.cfg } +# - { file: alembic.ini, location: /etc/anitya, dest: alembic.ini } + tags: + - config + +- name: create the database scheme + command: /usr/bin/python2 /usr/share/anitya/anitya_createdb.py + environment: + ANITYA_WEB_CONFIG: /etc/anitya/anitya.cfg + +- name: Install the configuration file of anitya + template: src={{ item.file }} + dest={{ item.location }}/{{ item.file }} + owner=root group=root mode=0600 + with_items: + - { file: anitya.cfg, location: /etc/anitya } + tags: + - config + diff --git a/roles/anitya/backend/templates/anitya.cfg b/roles/anitya/backend/templates/anitya.cfg new file mode 100644 index 0000000000..eed8c5c5f9 --- /dev/null +++ b/roles/anitya/backend/templates/anitya.cfg @@ -0,0 +1,26 @@ +# Beware that the quotes around the values are mandatory + +### Secret key for the Flask application +SECRET_KEY='{{ anitya_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://{{ anitya_db_user }}:{{ anitya_db_pass }}@{{ anitya_db_host }}/{{ anitya_db_name }}' + +# List of admins based on their openid +CNUCNU_WEB_ADMINS = [ + 'http://ralph.id.fedoraproject.org/', + 'http://pingou.id.fedoraproject.org/', +] + +# Fedora OpenID endpoint +{% if env == 'staging' %} +CNUCNU_WEB_FEDORA_OPENID = 'https://id.stg.fedoraproject.org' +{% else %} +CNUCNU_WEB_FEDORA_OPENID = 'https://id.fedoraproject.org' +{% endif %} + + +# This is required to fix login +PREFERRED_URL_SCHEME='https' diff --git a/roles/anitya/backend/templates/anitya_admin.cfg b/roles/anitya/backend/templates/anitya_admin.cfg new file mode 100644 index 0000000000..bb718b8519 --- /dev/null +++ b/roles/anitya/backend/templates/anitya_admin.cfg @@ -0,0 +1,26 @@ +# Beware that the quotes around the values are mandatory + +### Secret key for the Flask application +SECRET_KEY='{{ anitya_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://{{ anitya_db_admin }}:{{ anitya_db_admin_pass }}@{{ anitya_db_host }}/{{ anitya_db_name }}' + +# List of admins based on their openid +CNUCNU_WEB_ADMINS = [ + 'http://ralph.id.fedoraproject.org/', + 'http://pingou.id.fedoraproject.org/', +] + +# Fedora OpenID endpoint +{% if env == 'staging' %} +CNUCNU_WEB_FEDORA_OPENID = 'https://id.stg.fedoraproject.org' +{% else %} +CNUCNU_WEB_FEDORA_OPENID = 'https://id.fedoraproject.org' +{% endif %} + + +# This is required to fix login +PREFERRED_URL_SCHEME='https' diff --git a/roles/anitya/frontend/tasks/main.yml b/roles/anitya/frontend/tasks/main.yml new file mode 100644 index 0000000000..15f11d0267 --- /dev/null +++ b/roles/anitya/frontend/tasks/main.yml @@ -0,0 +1,37 @@ +--- +# Configuration for the anitya webapp + +- name: clean yum metadata + command: yum clean all + tags: + - packages + +- name: install needed packages + yum: pkg={{ item }} state=installed + with_items: + - anitya + - python-psycopg2 + - python-memcached + - libsemanage-python + - httpd + tags: + - packages + +- name: Install all the configuration file of anitya + template: src={{ item.file }} + dest={{ item.location }}/{{ item.file }} + owner=apache group=apache mode=0600 + with_items: + - { file: anitya.cfg, location: /etc/anitya } + - { file: anitya.conf, location: /etc/httpd/conf.d } + - { file: anitya.wsgi, location: /var/www/, dest: anitya.wsgi } + tags: + - config + notify: + - restart apache + +- name: set sebooleans so anitya can talk to the db + action: seboolean name=httpd_can_network_connect_db + state=true + persistent=true + diff --git a/roles/anitya/frontend/templates/anitya.cfg b/roles/anitya/frontend/templates/anitya.cfg new file mode 100644 index 0000000000..eed8c5c5f9 --- /dev/null +++ b/roles/anitya/frontend/templates/anitya.cfg @@ -0,0 +1,26 @@ +# Beware that the quotes around the values are mandatory + +### Secret key for the Flask application +SECRET_KEY='{{ anitya_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://{{ anitya_db_user }}:{{ anitya_db_pass }}@{{ anitya_db_host }}/{{ anitya_db_name }}' + +# List of admins based on their openid +CNUCNU_WEB_ADMINS = [ + 'http://ralph.id.fedoraproject.org/', + 'http://pingou.id.fedoraproject.org/', +] + +# Fedora OpenID endpoint +{% if env == 'staging' %} +CNUCNU_WEB_FEDORA_OPENID = 'https://id.stg.fedoraproject.org' +{% else %} +CNUCNU_WEB_FEDORA_OPENID = 'https://id.fedoraproject.org' +{% endif %} + + +# This is required to fix login +PREFERRED_URL_SCHEME='https' diff --git a/roles/anitya/frontend/templates/anitya.conf b/roles/anitya/frontend/templates/anitya.conf new file mode 100644 index 0000000000..f268b4e425 --- /dev/null +++ b/roles/anitya/frontend/templates/anitya.conf @@ -0,0 +1,23 @@ + +Alias /anitya/static /usr/lib/python2.7/site-packages/anitya/static/ + +WSGIDaemonProcess anitya user=apache maximum-requests=1000 display-name=anitya processes=2 threads=1 +WSGISocketPrefix run/wsgi +WSGIRestrictStdout On +WSGIRestrictSignal Off +WSGIPythonOptimize 1 + +WSGIScriptAlias /anitya /var/www/anitya.wsgi + + + WSGIProcessGroup anitya + + # Apache 2.4 + Require all granted + + + # Apache 2.2 + Order deny,allow + Allow from all + + diff --git a/roles/anitya/frontend/templates/anitya.wsgi b/roles/anitya/frontend/templates/anitya.wsgi new file mode 100644 index 0000000000..efa8a5f2b5 --- /dev/null +++ b/roles/anitya/frontend/templates/anitya.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['ANITYA_WEB_CONFIG'] = '/etc/anitya/anitya.cfg' + +## The following is only needed if you did not install anitya +## as a python module (for example if you run it from a git clone). +#import sys +#sys.path.insert(0, '/path/to/anitya/') + + +## The most import line to make the wsgi working +from anitya.app import APP as application +