---
- name: start httpd (provided in the apache role)
  service: name=httpd state=started

- name: ensure packages required for buildmaster are installed (dnf)
  dnf: name={{ item }} state=present
  with_items:
    - tmpwatch
  when: ansible_distribution_major_version|int > 21 and ansible_cmdline.ostree is not defined

- name: create artifacts directory
  file: path={{ item }} state=directory owner=buildmaster group=buildmaster mode=0775 setype=httpd_sys_content_t
  with_items:
  - /srv/taskotron
  - /srv/taskotron/artifacts

- name: copy artifacts httpd config
  template: src={{ item }} dest=/etc/httpd/conf.d/artifacts.conf owner=root group=root
  with_first_found:
    - artifacts.conf.j2.{{ deployment_type }}
    - artifacts.conf.j2
  notify:
    - reload httpd

- name: allow httpd to read artifacts on nfs
  seboolean: name=httpd_use_nfs state=yes persistent=yes

- name: copy cronjob for cleaning old taskotron artifacts and buildmaster logs
  template: src=taskotron-clean.cron.j2 dest=/etc/cron.d/taskotron-clean.cron owner=root group=root mode=0644
