---
# Tasklist for setting up freemedia cgi.

- name: install needed php packages
  package:
    state: present
    name:
    - php
  notify:
  - reload httpd
  tags:
  - packages

- name: setup /srv/web/freemedia directory
  file: path=/srv/web/freemedia owner=root group=root mode=0755 state=directory
  tags:
  - config

- name: install /etc/httpd/conf.d/freemedia-app.conf file
  copy: >
    src="freemedia-app.conf"
    dest="/etc/httpd/conf.d/freemedia-app.conf"
    owner=root
    group=root
    mode=0644
  notify:
  - reload httpd
  tags:
  - config

- name: install /srv/web/freemedia/FreeMedia-form.html file
  copy: >
    src="FreeMedia-close.html"
    dest="/srv/web/freemedia/FreeMedia-form.html"
    owner=root
    group=root
    mode=0644
  tags:
  - config

- name: install /srv/web/freemedia/process.php file
  copy: >
    src="process.php"
    dest="/srv/web/freemedia/process.php"
    owner=root
    group=root
    mode=0644
  tags:
  - config

- name: install /srv/web/freemedia/FreeMedia-error.html file
  copy: >
    src="FreeMedia-error.html"
    dest="/srv/web/freemedia/FreeMedia-error.html"
    owner=root
    group=root
    mode=0644
  tags:
  - config

- name: install /srv/web/freemedia/FreeMedia-error-embargoed-destination.html file
  copy: >
    src="FreeMedia-error-embargoed-destination.html"
    dest="/srv/web/freemedia/FreeMedia-error-embargoed-destination.html"
    owner=root
    group=root
    mode=0644
  tags:
  - config

- name: check the selinux context freemedia
  command: matchpathcon /srv/web/freemedia
  register: freemediacontext
  check_mode: no
  changed_when: "1 != 1"
  ignore_errors: true
  tags:
  - config
  - selinux

- name: /srv/web/freemedia file contexts
  command: semanage fcontext -a -t httpd_sys_content_t "/srv/web/freemedia(/.*)?"
  when: freemediacontext.stdout.find('httpd_sys_content_t') == -1
  tags:
  - config
  - selinux
