---
# Configuration for the Fedora Notifications webapp

- name: install needed packages
  yum: pkg={{ item }} state=present
  with_items:
  - python-fmn-web
  - python-psycopg2
  - libsemanage-python

- name: copy fmn app configuration
  template: >
    src={{ item }} dest=/etc/fedmsg.d/{{ item }}
    owner=apache group=apache mode=0600
  with_items:
  - fmn.web.py
  notify:
  - restart apache

- name: destroy a bogus config file brought in by python-datanommer-models
  file: dest=/etc/fedmsg.d/datanommer.py state=absent
  notify:
  - restart apache

- name: setup symlink to fedora theme
  file: >
    src=/usr/share/fmn.web/static/bootstrap-3.0.2-fedora
    dest=/usr/share/fmn.web/static/bootstrap
    state=link

- name: copy fmn httpd config
  copy: >
    src=fmn.web.conf dest=/etc/httpd/conf.d/fmn.web.conf
    owner=apache group=apache mode=0644
  notify:
  - restart apache

- name: copy custom wsgi file
  copy: src=fmn.web.wsgi dest=/usr/share/fmn.web/fmn.web.wsgi mode=0644
  notify:
  - restart apache

- name: copy app configuration
  template: >
    src=fmn.web.cfg dest=/etc/fmn.web.cfg
    owner=root group=apache mode=0640
  notify:
  - restart apache

- name: create live docs directory
  file: >
    dest=/usr/lib/python2.6/site-packages/fmn/web/docs/
    state=directory

- name: copy live docs
  copy: src={{ item }} dest=/usr/lib/python2.6/site-packages/fmn/web/docs
  with_fileglob: fedora-sitedocs/*.rst

- name: apply selinux type to static files
  file: >
    dest=/usr/share/fmn.web/static
    setype=httpd_sys_content_t
    state=directory
    recurse=yes

- name: ensure selinux lets httpd talk to postgres
  seboolean: name=httpd_can_network_connect_db state=yes persistent=yes
