---
# Configuration for the mdapi webapp

- name: install needed packages
  dnf: pkg={{ item }} state=present
  with_items:
  - mdapi
  - python3-fedmsg-core
  - policycoreutils-python-utils
  tags:
  - mdapi
  - packages

- name: create all the directory for the configuration file
  file: state=directory path=/etc/mdapi
  tags:
  - mdapi
  - config

- name: Install the meta-data fetch cron job
  when: inventory_hostname.startswith(('mdapi01'))
  template:
    src: "{{ item | basename }}"
    dest: "{{ item }}"
  with_items:
  - /etc/cron.d/mdapi.cron
  - /etc/mdapi/mdapi.cfg
  tags:
  - mdapi
  - config

- name: stop apache service
  service: name=httpd enabled=no state=stopped
  ignore_errors: true
  tags:
  - mdapi
  - service

- name: start the mdapi service
  service: name=mdapi enabled=yes state=started
  ignore_errors: true
  tags:
  - mdapi
  - service
