---
# Configuration for the tahrir webapp


# TODO -- add the cronjob


- name: install needed packages
  yum: pkg={{ item }} state=present
  with_items:
  - fedora-tagger
  - python-psycopg2
  - python-memcached
  - python-sqlalchemy0.8
  - python-webob
  - koji
  tags:
  - packages

- name: link the README into the right place because tagger is ridiculous
  file: >
    src=/usr/lib/python2.6/site-packages/fedoratagger/README.rst
    dest=/usr/lib/python2.6/site-packages/README.rst
    state=link
  tags:
  - config
  - ridiculous

- name: make the cache directory
  file: >
    path=/var/cache/fedoratagger
    state=directory
    owner=apache group=apache mode=0755
  tags:
  - config

- name: copy tagger app configuration
  template: >
    src=fedoratagger.cfg.j2
    dest=/etc/fedoratagger/fedoratagger.cfg
    owner=apache
    group=apache
    mode=0600
  tags:
  - config
  notify:
  - restart apache

- name: copy tagger httpd config
  copy: >
    src=fedoratagger-app.conf
    dest=/etc/httpd/conf.d/fedoratagger.conf
    owner=apache
    group=apache
    mode=0644
  tags:
  - config
  notify:
  - restart apache

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

- name: check log file
  command: stat /var/log/fedoratagger.log
  register: logstat
  always_run: yes
  changed_when: "1 != 1"

- name: ensure cronjob log file is writable
  file: >
    dest=/var/log/fedoratagger.log
    state=touch
    owner=apache group=apache mode=0755
  tags:
  - cron
  - config
  when: logstat.rc == 1

- name: setup the update-with-new-packages cronjob
  copy: >
    src=cron-tagger-update-db
    dest=/etc/cron.d/cron-tagger-update-db
  tags:
  - cron
  - config
  when: install_tagger_cron

- name: setup the remove-old-and-crusty-packages cronjob
  copy: >
    src=cron-tagger-remove-retired
    dest=/etc/cron.d/cron-tagger-remove-retired
  tags:
  - cron
  - config
  when: install_tagger_cron
