# This role installs relval (if needed) and deploys a cron drop-in to
# run `relval testcase-stats` for the next Fedora release once an hour
# and dump the output to a configured location. It also drops an httpd
# config snippet to enable directory indexing and override proxying
# for the location on openQA servers (like the one we expect this role
# to be deployed on). It doesn't actually configure the server to serve
# the directory out - we're currently relying on the openQA Apache
# config to do that, if this role gets split out from the openQA server
# we would need to change that.

# Required vars
# - testcase_stats_output_dir
##      string - Directory where the output should be written.
# - FedoraCycleNumber
##      int - the current Fedora release number. Report will be
##            produced for the release *after* this one.

# We seem to need this to get FedoraCycleNumber in Fedora infra. If
# you're running this role elsewhere, make your own arrangements
- name: Include vars
  include_vars: dir=/srv/web/infra/ansible/vars/all/ ignore_files=README
  when: "deployment_type is defined"

- name: Install required packages
  package:
    name: relval
    state: present
  tags:
  - packages

- name: Deploy the cronjob
  template: src=testcase_stats.cron dest=/etc/cron.hourly/testcase_stats owner=root group=root mode=0755

- name: Set up Apache config
  copy: src=testcase_stats.conf.httpd dest=/etc/httpd/conf.d/01-testcase_stats.conf owner=root group=root mode=0644
  notify:
  - reload httpd
  tags:
  - config
