---

- name: Check that mandatory packages are installed
  urpmi: name={{ item }} state=installed no_recommends=yes
  with_items:
    - mariadb
    - sympa-www
    - perl-DBD-mysql
    - perl-Crypt-CipherSaber
    - perl-CGI-Fast
  tags: sympa

- name: Check /etc/sympa rights
  file: path=/etc/sympa mode=0775 owner=root group=sympa state=directory
  tags: sympa

- name: Fix sympa link
  file: src=/usr/sbin/queue dest=/usr/bin/queue state=link owner=root group=root 
  tags: sympa

- name: Fix sympa-www setup
  copy: src=files/sympa.conf dest=/etc/httpd/conf/sites.d/sympa.conf mode=0644 owner=root group=root backup=yes
  notify:
    - reload httpd
  tags: sympa

- name: Check sympa.conf
  lineinfile: destfile=/etc/sympa/sympa.conf state=present line='{{ item }}' owner=root group=sympa mode=0640 backup=yes
  with_items:
    - 'key_passwd {{ keypwd }}'
    - 'db_user sympa'
    - 'db_passwd {{ dbpwd }}'
    - 'domain {{ domain }}'
    - 'listmaster  listmaster@mondorescue.org,bruno@mondorescue.org,bruno@project-builder.org,bruno@hyper-linux.org,bruno.cornec@hpe.com,bruno@victoria.frmug.org'
    - 'http_host http://www.{{ domain }}/sympa'
    - 'wwsympa_url http://www.{{ domain }}/sympa'
    - 'title MondoRescue Mailing lists service'
    - 'use_fast_cgi 1'
  notify:
    - restart sympa
  tags: sympa

- name: Check that mariadb is running and enabled
  service: name=mysqld state=started enabled=yes
  tags: sympa

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