---
- name: upgrade copr backend
  hosts: copr_back_dev_aws:copr_back_aws
  user: root
  gather_facts: True

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  tasks:
  - name: Generic upgrade tasks for copr servers
    import_tasks: _generic_tasks.yml

  - name: Upgrade copr-backend packages
    dnf:
      state: latest
      name:
      - copr-backend
      - copr-cli  # copr-ping cron job needs this
      - copr-selinux
      - python3-copr
      - python3-copr-common
      - python3-copr-messaging
      - prunerepo
      update_cache: true

  - name: Upgrade createrepo_c from updates-testing, when needed
    dnf: state=latest
         name=createrepo_c
         enablerepo=updates-testing
    when: ansible_facts.packages['createrepo_c'][0].version is version('0.15.5', '<')

  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"
