---

- name: Check that docutils is installed
  urpmi: name=python-docutils state=installed no-recommends=yes
  tags: trac

- name: Check that pip is installed
  urpmi: name=python-pip state=installed no-recommends=yes
  tags: trac

- name: Install trac with fcgi
  urpmi: name=trac-fcgi state=installed no-recommends=yes
  tags: trac

- name: Install trac plugins
  pip: name={{ item }} state=present umask=0022
  with_items:
    - TracAccountManager
    - TracTags
    - TracRobotsTxt
    - "TracSpamFilter<1.2"
#  register: result
  notify: upgrade trac
  tags: trac

#- name: Upgrade trac with new plugins
#  command: trac-admin {{ item }} upgrade
#  with: 
#   - /prj/trac/mondorescue.env
#   - /prj/trac/project-builder.env
#   - /prj/trac/dploy.env
#   - /prj/trac/pusk.env
#   - /prj/trac/uuwl.env
#  tags: trac

- name: Configure trac
  template: src=templates/trac.ini dest=/prj/trac/trac.ini owner=apache group=apache mode=0644 backup=yes
  notify:
    - restart httpd
  tags: trac

- name: Configure trac for project-builder.org
  copy: src=files/project-builder.ini dest=/prj/trac/project-builder.env/conf/trac.ini owner=apache group=apache mode=0644 backup=yes
  notify:
    - restart httpd
  tags: trac

- name: Configure trac for mondorescue.org
  copy: src=files/mondorescue.ini dest=/prj/trac/mondorescue.env/conf/trac.ini owner=apache group=apache mode=0644 backup=yes
  notify:
    - restart httpd
  tags: trac

- name: Configure trac for dploy.org
  copy: src=files/dploy.ini dest=/prj/trac/dploy.env/conf/trac.ini owner=apache group=apache mode=0644 backup=yes
  notify:
    - restart httpd
  tags: trac

- name: Configure trac for uuwl
  copy: src=files/uuwl.ini dest=/prj/trac/uuwl.env/conf/trac.ini owner=apache group=apache mode=0644 backup=yes
  notify:
    - restart httpd
  tags: trac

- name: Configure trac for pusk
  copy: src=files/pusk.ini dest=/prj/trac/pusk.env/conf/trac.ini owner=apache group=apache mode=0644 backup=yes
  notify:
    - restart httpd
  tags: trac

- name: Check that trac is running and enabled
  service: name=httpd state=started enabled=yes
  tags: trac
