---
# tasks file for loopabull

- name: Install required packages
  package: name="{{ item }}" state=present
  with_items:
    - git
    - loopabull
    # Required for flag_build_commits
    - python2-koji
    - python2-requests
  tags:
  - loopabull

- name: configure loopabull
  template:
    src: loopabull.yml.j2
    dest: /etc/loopabull.yml
  notify: restart loopabull
  tags:
  - loopabull

- name: ensure /srv/private dir exists with the expected permissions
  file:
    path: "/srv/private"
    state: directory
    mode: 0640
    owner: root
    group: sysadmin-main
  tags:
  - loopabull

- name: place the private variables file
  copy:
    src: "{{ private }}/vars_loopabull.yml"
    dest: "/srv/private/vars_loopabull.yml"
    mode: 0640
    owner: root
    group: sysadmin-main
  tags:
  - loopabull

- name: clone the playbooks repo into playbooks dir
  git:
    repo: "https://pagure.io/Fedora-Infra/loopabull-tasks.git"
    dest: "/srv/loopabull-tasks/"
  tags:
  - loopabull

- name: Install the loopabull@.service template
  copy:
    src: "loopabull@.service"
    dest: "/usr/lib/systemd/system/loopabull@.service"
  notify: restart loopabull
  tags:
  - loopabull

- name: start and enable loopabull@
  service:
    name: "{{ item }}"
    state: started
    enabled: yes
  with_items:
    - loopabull
    - loopabull@1
    - loopabull@2
    - loopabull@3
    - loopabull@4
    - loopabull@5
  tags:
  - loopabull

