---
- name: add repo
  action: copy src=cabal-install.repo dest=/etc/yum.repos.d/cabal-install.repo
  tags:
  - cabal-install
  - packages
  - repo

- name: install needed packages
  yum: pkg={{ item }} state=present
  with_items:
  - ghc
  - ghc-devel
  - git
  - cabal-install
  - zeromq3-devel
  tags:
  - packages
  - fedmsg2statsd

- name: Clone fedmsg2statsd repo (this needs to be packaged at some point)
  git: accept_hostkey=yes clone=yes repo=https://github.com/fedora-infra/fedmsg2statsd.git update=yes dest=/opt/fedmsg2statsd
  tags:
  - fedmsg2statsd

- name: Update cabal metadata
  shell: cabal update
  tags:
  - fedmsg2statsd

- name: Start a cabal sandbox
  shell: chdir=/opt/fedmsg2statsd cabal sandbox init
  tags:
  - fedmsg2statsd

- name: Install fedmsg2statsd in the sandbox
  shell: chdir=/opt/fedmsg2statsd cabal install -j
  tags:
  - fedmsg2statsd

- name: Installing systemd service file
  copy: >
    src=fedmsg2statsd.service
    dest=/usr/lib/systemd/system/fedmsg2statsd.service
  tags:
  - config
  - fedmsg2statsd
  notify:
  - restart fedmsg2statsd

- name: Set fedmsg2statsd to run on boot
  service: name=fedmsg2statsd enabled=yes state=running
  tags:
  - service
  - fedmsg2statsd
