---

- name: Check that Apache is installed
  urpmi: name=apache state=installed no-recommends=yes
  tags: httpd

- name: Configure Apache log directories
  file: path=/var/log/httpd/{{ item }} state=directory owner=apache group=apache mode=0755
  with_items:
    - www.mondorescue.org
    - www.mondorescue.com
    - www1.mondorescue.org
    - oldwww.mondorescue.org
    - mondorescue.hpintelco.org
    - www.project-builder.org
    - www1.project-builder.org
    - pusk.project-builder.org
    - uuwl.project-builder.org
    - www.dploy.org
    - www1.dploy.org

- name: Configure Apache
  template: src={{ item }} dest=/etc/httpd/conf/vhosts.d/{{ item | basename }} owner=root group=root mode=0644 backup=yes
  with_fileglob: [ 'templates/*.conf' ]
  notify:
    - restart httpd
  tags: httpd

- name: Configure Apache upload max
  lineinfile: path=/etc/httpd/conf/conf.d/fcgid.conf regexp='^[     ]*FcgidMaxRequestLen ' insertafter='[   ]*^#FcgidMaxRequestLen ' line='    FcgidMaxRequestLen 3000000'
  notify:
    - restart httpd
  tags: httpd

- name: Setup httpd restart by cron
  cron: name=httpd-restart minute=43 hour=23 weekday=0 user=root job="/usr/bin/systemctl restart httpd" cron_file=httpd-restart state=present backup=yes 
  tags: httpd

- name: Configure Apache logrotate
  copy: src=files/mondorescue.logrot dest=/etc/logrotate.d/mondorescue owner=root group=root mode=0644 backup=yes
  tags: httpd

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