diff --git a/playbooks/groups/statscache.yml b/playbooks/groups/statscache.yml index 452a5e8b6b..00f08a585f 100644 --- a/playbooks/groups/statscache.yml +++ b/playbooks/groups/statscache.yml @@ -63,5 +63,5 @@ handlers: - include: "{{ handlers }}/restart_services.yml" - #roles: - # TODO -- include statscache/backend here + roles: + - statscache/backend diff --git a/roles/statscache/backend/tasks/main.yml b/roles/statscache/backend/tasks/main.yml new file mode 100644 index 0000000000..fa0a4892db --- /dev/null +++ b/roles/statscache/backend/tasks/main.yml @@ -0,0 +1,35 @@ +--- +# Configuration for the notifications consumer + +- name: install needed packages + yum: pkg={{ item }} state=present + with_items: + - statscache-consumer + - statscache-plugins + - python-psycopg2 + - libsemanage-python + tags: + - notifs + - notifs/backend + +- name: copy database configuration + template: > + src={{ item }} dest=/etc/fedmsg.d/{{ item }} + owner=fedmsg group=fedmsg mode=0600 + with_items: + - statscache.py + notify: + - restart fedmsg-hub + tags: + - notifs + - notifs/backend + +- name: copy the alembic configuration for DBAs + template: > + src=alembic.ini dest=/usr/share/statscache/alembic.ini + owner=root group=sysadmin-dba mode=0660 + notify: + - restart fedmsg-hub + tags: + - notifs + - notifs/backend diff --git a/roles/statscache/backend/templates/alembic.ini b/roles/statscache/backend/templates/alembic.ini new file mode 100644 index 0000000000..f62e08c0f4 --- /dev/null +++ b/roles/statscache/backend/templates/alembic.ini @@ -0,0 +1,53 @@ +# A generic, single database configuration. + +[alembic] +# path to migration scripts +script_location = /usr/share/statscache/alembic/ + +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# max length of characters to apply to the +# "slug" field +#truncate_slug_length = 40 + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + +sqlalchemy.url = postgres://statscache:{{statscache_db_password}}@db01/statscache + +# 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/statscache/backend/templates/statscache.py b/roles/statscache/backend/templates/statscache.py new file mode 100644 index 0000000000..b088d7ced0 --- /dev/null +++ b/roles/statscache/backend/templates/statscache.py @@ -0,0 +1,37 @@ +import datetime + + +config = { + "statscache.datagrepper.profile": False, + + # Consumer stuff + "statscache.consumer.enabled": True, + + "statscache.sqlalchemy.uri": "postgres://statscache:{{statscache_db_password}}@db01/statscache", + + # stats models will go back at least this far (current value arbitrary) + "statscache.consumer.epoch": datetime.datetime(year=2015, month=8, day=8), + + # stats models are updated at this frequency + "statscache.producer.frequency": datetime.timedelta(seconds=1), + + # Configuration of web API + "statscache.app.maximum_rows_per_page": 100, + "statscache.app.default_rows_per_page": 100, + + # Turn on logging for statscache + "logging": dict( + loggers=dict( + statscache={ + "level": "DEBUG", + "propagate": False, + "handlers": ["console"], + }, + statscache_plugins={ + "level": "DEBUG", + "propagate": False, + "handlers": ["console"], + }, + ), + ), +}