---

- name: install bugbot utilities
  pacman: name=python-irc,python-beautifulsoup4,python-lxml state=present

- name: receive valid signing keys
  command: /usr/bin/gpg --keyserver keys.openpgp.org --auto-key-locate wkd,keyserver --locate-keys {{ item }}
  with_items: '{{ bugbot_pgp_emails }}'
  register: gpg
  changed_when: "gpg.rc == 0"

- name: clone bugbot source
  git:
    repo: https://gitlab.archlinux.org/archlinux/bugbot.git
    dest: /srv/bugbot
    force: true
    verify_commit: true
    gpg_whitelist: '{{ bugbot_pgp_keys }}'
    version: '{{ bugbot_version }}'

- name: install env file
  template: src=bugbot.j2 dest=/srv/bugbot/env owner=root group=root mode=0600

- name: install bugbot systemd service
  copy: src=bugbot.service dest=/etc/systemd/system/bugbot.service owner=root group=root mode=0644

- name: start and enable bugbot service
  systemd: name=bugbot.service enabled=yes state=started daemon_reload=yes
