---
- name: Check that docutils is installed
  urpmi: name=python-docutils state=installed no_recommends=yes

- name: Check that pip is installed
  urpmi: name=python-pip state=installed no_recommends=yes

- name: Install trac with fcgi
  urpmi: name=trac-fcgi state=installed no_recommends=yes

- name: Install trac plugins dir
  file: path=/prj/trac/plugins mode=0775 owner=apache group=apache state=directory

  # Do it only at upgrade of trac:
  #- name: Install trac plugins
  #command: pip install --no-deps --upgrade -t /usr/lib/python3.10/site-packages/ {{ item }}
  #with_items:
  #- TracAccountManager
  #- TracTags
  #- TracRobotsTxt
  #- TracSpamFilter
  #- TracStats
  #notify: upgrade trac

  # Do it only at upgrade of trac:
#- name: Upgrade trac with new plugins
#  command: trac-admin /prj/trac/{{ item }}.env upgrade
#  loop: "{{ prj }}"

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

- name: Configure trac svn hook
  copy: src=templates/trac-svn-hook dest=/prj/trac/trac-svn-hook owner=apache group=apache mode=0755 backup=yes

- name: Configure svn post-commit hook
  lineinfile: path="/prj/svn/{{ item }}/hooks/post-commit" state=present line='/prj/trac/trac-svn-hook $1 $2' owner=bruno group=bruno mode=0755 backup=yes create=true
  loop: "{{ prj }}"

- name: "Configure trac ini file for the projects"
  copy: src="files/{{ item }}.ini" dest="/prj/trac/{{ item }}.env/conf/trac.ini" owner=apache group=apache mode=0644 backup=yes
  loop: "{{ prj }}"
  notify:
    - restart httpd

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