---
# Configuration for the notifications consumer

- name: install needed packages
  package: name={{ item }} state=present
  with_items:
  - python-fmn
  - python-psycopg2
  - libsemanage-python
  # Needed to produce nice long emails about koji builds
  - koji
  tags:
  - notifs
  - notifs/backend

- name: copy database configuration
  template: >
    src={{ item }} dest=/etc/fedmsg.d/{{ item }}
    owner=fedmsg group=fedmsg mode=0600
  with_items:
  - fmn.consumer.py
  notify:
  - restart fedmsg-hub
  tags:
  - notifs
  - notifs/backend

- name: Install fmn SSE configuration
  template: >
    src={{ item }} dest=/etc/fedmsg.d/{{ item }}
    owner=fedmsg group=fedmsg mode=0600
  with_items:
  - fmn.sse.py
  when: env == "staging"
  notify:
  - restart fedmsg-hub
  tags:
  - notifs
  - notifs/backend

- name: copy the alembic configuration for DBAs
  template: >
    src=alembic.ini dest=/usr/share/fmn/alembic.ini
    owner=root group=sysadmin-dba mode=0660
  notify:
  - restart fedmsg-hub
  tags:
  - notifs
  - notifs/backend

- name: copy over admin utility scripts
  copy: src=bin/{{ item }} dest=/usr/local/bin/{{ item }} owner=root group=root mode=0755
  with_items:
  - fmn-create-account
  - fmn-disable-account
  tags:
  - notifs
  - notifs/backend

- name: override the default syslog logrotate file
  copy: src=syslog-logrotate dest=/etc/logrotate.d/rsyslog
  tags:
  - notifs
  - notifs/backend

- name: start the workers and the backend
  service: name={{item}} enabled=yes state=started
  with_items:
  - fmn-backend@1
  - fmn-worker@1
  - fmn-worker@2
  - fmn-worker@3
  - fmn-worker@4
  - fmn-worker@5
  - fmn-worker@6
  - fmn-celerybeat
  tags:
  - notifs
  - notifs/backend
