- name: install apache/mysql/python
  action: yum name={{ item }} state=latest
  notify:
    - restart httpd
    - restart mysql
  with_items:
    - httpd
    - mod_wsgi
    - mod_ssl
    - mysql
    - mysql-server
    - mysql-devel
    - MySQL-python
    - git
    - util-linux
    - python-virtualenv
    - openldap-devel

- name: copy apache config
  template: src=httpd.conf.j2 dest=/etc/httpd/conf.d/rattic.conf
  notify: reload httpd

- name: create apps dir
  action: file dest=/opt/apps state=directory

- name: checkout RatticWeb.wiki
  action: git repo=git://github.com/tildaslash/RatticWeb.wiki.git dest=/opt/apps/RatticWeb.wiki force=no version={{ release }}

- name: checkout RatticWeb
  action: git repo=git://github.com/tildaslash/RatticWeb.git dest=/opt/apps/RatticWeb force=no version={{ release }}
  notify:
    - sync db
    - migrate db
    - generate static
    - restart httpd

- name: Setup virtualenv
  pip: requirements=/opt/apps/RatticWeb/requirements.txt virtualenv=/opt/apps/RatticWeb.venv
  notify:
    - restart httpd

- name: create static dir
  action: file dest=/opt/apps/RatticWeb/static state=directory
  notify: generate static

- name: set mysql to start
  action: service name=mysqld state=started enabled=yes

- name: set apache to start
  action: service name=httpd state=started enabled=yes

- name: create MySQL database
  action: mysql_db db=rattic state=present
  notify:
    - migrate db
    - sync db
    - create initial user

- name: remove MySQL test database
  action: mysql_db db=test state=absent

- name: create MySQL user
  action: mysql_user name=rattic password=allthepass priv=rattic.*:ALL state=present

- name: setup RatticWeb
  copy: src=local.cfg dest=/opt/apps/RatticWeb/conf/local.cfg
  notify: restart httpd

