# This role reports Autocloud results to ResultsDB. There should
# always be exactly one host in infra with this role set up and
# autocloudreporter_prod set to True, so all results are reported
# once.
#
# Required vars
#
# Required vars with defaults
# - autocloudreporter_prod
##       bool - whether this is the production instance. **SHOULD ONLY
##              EVER BE TRUE ON ONE SYSTEM IN THE WORLD**
##       default - False

- name: Install required packages
  dnf:
    name: ['python3-fedfind', 'python3-fedmsg', 'python3-resultsdb_api',
           'python3-resultsdb_conventions-fedora', 'python3-setuptools']
    state: present
  tags:
  - packages

- name: Check out autocloudreporter
  git:
    repo: https://pagure.io/fedora-qa/autocloudreporter.git
    dest: /root/autocloudreporter
  register: gitacr

- name: Install autocloudreporter
  command: "python3 setup.py install --nodeps"
  args:
    chdir: /root/autocloudreporter
  when: "gitacr is changed"
  notify:
  - restart fedmsg-hub

- name: Enable fedmsg consumer
  template: src=autocloudreporter.py.j2 dest=/etc/fedmsg.d/autocloudreporter.py owner=root group=root mode=0644
  notify:
  - restart fedmsg-hub
  tags:
  - config
