---
- name: Install the httpd package, just to get the apache group on the system.
  package:
    pkg: httpd
    state: present
  tags:
  - packages
  - odcs
  - odcs/backend
- name: Make sure Python2 fedmsg-hub isn't running.
  service:
    name: fedmsg-hub
    state: stopped
    enabled: false
  tags:
  - odcs
  - odcs/backend
- name: Make sure httpd isn't running.
  service:
    name: httpd
    state: stopped
    enabled: false
  tags:
  - odcs
  - odcs/backend
- name: generate the ODCS koji config
  template:
    src: etc/koji.conf.d/odcs.conf.j2
    dest: /etc/koji.conf.d/odcs.conf
    owner: odcs
    group: fedmsg
    mode: 0440
  notify:
  - restart fedmsg-hub-3
  tags:
  - odcs
  - odcs/backend
- name: add the odcs user to the apache group
  user:
    name: odcs
    group: apache
    groups: apache
    append: true
  notify:
  - restart fedmsg-hub-3
  tags:
  - odcs
  - odcs/backend
- name: migrate the database
  command: "{{ item }}"
  with_items:
  - odcs-manager upgradedb
  - odcs-manager db migrate
  become: yes
  become_user: odcs
  when: odcs_migrate_db
  tags:
  - odcs
  - odcs/backend
- name: Make sure fedmsg-hub-3 is running (we used to turn it off).
  service:
    name: fedmsg-hub-3
    state: started
    enabled: true
  tags:
  - odcs
  - odcs/backend
