---
# Configuration for the notifications consumer

- name: install needed packages
  yum: pkg={{ item }} state=installed
  with_items:
  - koji
  - fedmsg
  - python-paramiko
  - python-fedimg
  tags:
  - fedimg

- name: except for python-libcloud, we need the super latest version
  yum: pkg={{ item }} state=latest enablerepo=epel-testing
  with_items:
  - python-libcloud
  tags:
  - fedimg

- name: install latest fedimg
  yum: pkg={{ item }} state=latest
  with_items:
  - python-fedimg
  tags:
  - fedimg

- name: copy base configuration
  template: >
    src=fedimg.cfg dest=/etc/fedimg.cfg
    owner=fedmsg group=fedmsg mode=0700
  notify:
  - restart fedmsg-hub
  tags:
  - fedimg

- name: copy koji fedmsg consumer
  template: >
    src=fedmsg.d/fedimg.py dest=/etc/fedmsg.d/fedimg.py
    owner=fedmsg group=fedmsg mode=0600
  notify:
  - restart fedmsg-hub
  tags:
  - fedimg

- name: make pki directory
  file: dest=/etc/pki/fedimg/ state=directory
        owner=fedmsg group=fedmsg mode=0500
  tags:
  - fedimg

- name: copy keys into pki directory for staging
  copy: src={{private}}/files/fedimg/{{item}} dest=/etc/pki/fedimg/{{item}}
        owner=fedmsg group=fedmsg mode=0400
  with_items:
  - fedimg-dev
  - fedimg-dev.pub
  notify:
  - restart fedmsg-hub
  when: env == "staging"
  tags:
  - fedimg

- name: copy keys into pki directory for production
  copy: src={{private}}/files/fedimg/{{item}} dest=/etc/pki/fedimg/{{item}}
        owner=fedmsg group=fedmsg mode=0400
  with_items:
  - fedimg-prod
  - fedimg-prod.pub
  notify:
  - restart fedmsg-hub
  when: env != "staging"
  tags:
  - fedimg
