#
# This playbook creates users and queues for specific applications that are not
# elsewhere in Ansible.
#


- name: CoreOS user
  run_once: true
  include_role:
    name: rabbit/user
  vars:
    username: coreos{{ env_suffix }}


- name: CentOS CI
  run_once: true
  include_role:
    name: rabbit/queue
  vars:
    username: centos-ci{{ env_suffix }}
    queue_name: centos-ci{{ env_suffix }}
    # TTL: 10 days (in miliseconds)
    message_ttl: 864000000
    routing_keys:
      # This routing key is for testing purposes only
      - "org.centos.ci.#"

- name: OSCI
  run_once: true
  include_role:
    name: rabbit/queue
  vars:
    username: osci-pipelines{{ env_suffix }}
    queue_name: "{{ osci_pipeline_queue }}{{ env_suffix }}"
    message_ttl: 864000000
    sent_topics: ^org\.fedoraproject\.{{ env_short }}\.ci\..*
  loop:
    - "osci-pipelines{{ env_suffix }}-queue-0"
    - "osci-pipelines{{ env_suffix }}-queue-1"
    - "osci-pipelines{{ env_suffix }}-queue-2"
    - "osci-pipelines{{ env_suffix }}-queue-4"
    - "osci-pipelines{{ env_suffix }}-queue-5"
    - "osci-pipelines{{ env_suffix }}-queue-6"
    - "osci-pipelines{{ env_suffix }}-queue-7"
    - "osci-pipelines{{ env_suffix }}-queue-9"
    - "osci-pipelines{{ env_suffix }}-queue-10"
    - "osci-pipelines{{ env_suffix }}-queue-11"
    - "osci-pipelines{{ env_suffix }}-queue-12"
    - "osci-pipelines{{ env_suffix }}-queue-13"
    - "osci-pipelines{{ env_suffix }}-queue-14"
    - "osci-pipelines{{ env_suffix }}-queue-15"
    - "osci-pipelines{{ env_suffix }}-queue-16"
  loop_control:
    loop_var: osci_pipeline_queue
  tags:
    - osci-pipelines

- name: Fedora Build Checks
  run_once: true
  include_role:
    name: rabbit/queue
  vars:
     username: fedora-build-checks{{ env_suffix }}
     queue_name: fedora-build-checks{{ env_suffix }}
     routing_keys:
      - "org.centos.ci.#"

- name: copr
  run_once: true
  include_role:
    name: rabbit/user
  vars:
    username: copr{{ env_suffix }}
    sent_topics: ^org\.fedoraproject\.{{ env_short }}\.copr\..*

- name: CentOS Stream
  run_once: true
  include_role:
    name: rabbit/queue
  vars:
    username: alt-src{{ env_suffix }}
    queue_name: alt-src{{ env_suffix }}
    # TTL: 10 days (in miliseconds)
    message_ttl: 864000000
    routing_keys:
      # This routing key is for testing purposes only
      - "org.centos.stream.#"
    thresholds:
      warning:  1000
      critical: 10000

# CENTOS GITLAB BEGIN
- name: CentOS Gitlab Queue
  run_once: true
  include_role:
    name: rabbit/queue
  vars:
    username: gitlab-centos{{ env_suffix }}
    queue_name: gitlab-centos{{ env_suffix }}
    # TTL: 10 days (in miliseconds)
    message_ttl: 864000000
    routing_keys:
      - "org.centos.{{ env_short }}.gitlab.#"
# CENTOS GITLAB END

# CENTOS KOJI BEGIN
- name: CentOS Koji User (maybe unused, to remove)
  run_once: true
  include_role:
    name: rabbit/user
  vars:
    username: koji-centos{{ env_suffix }}
    sent_topics: ^org\.centos\.{{ env_short }}\.buildsys\..*
  when: env != 'staging'

- name: CentOS Stream Koji User
  run_once: true
  include_role:
    name: rabbit/user
  vars:
    username: centos-koji
    sent_topics: ^org\.centos\.{{ env_short }}\.buildsys\..*

- name: CBS Koji User
  run_once: true
  include_role:
    name: rabbit/user
  vars:
    username: cbs{{ env_suffix }}
    sent_topics: ^org\.centos\.{{ env_short }}\.cbs\.buildsys\..*
# CENTOS KOJI END

# CENTOS RESULSDB BEGIN
- name: CentOS ResultsDB User
  run_once: true
  include_role:
    name: rabbit/user
  vars:
    username: resultsdb-centos{{ env_suffix }}
    sent_topics: ^org\.centos\.{{ env_short }}\.resultsdb\..*
# CENTOS RESULTSDB END

# CENTOS robosignatory BEGIN

- name: CentOS Stream robosignatory queue
  run_once: true
  include_role:
    name: rabbit/queue
  vars:
    username: centos-stream-robosignatory
    sent_topics: ^org\.centos\.{{ env_short }}\.(robosignatory|coreos)\..*\.finished$
    queue_name: centos-stream-robosignatory
    # TTL: 10 days (in miliseconds)
    message_ttl: 864000000
    routing_keys:
      - "org.centos.*.pungi.compose.ostree"
      - "org.centos.*.coreos.build.request.artifacts-sign"
      - "org.centos.*.coreos.build.request.ostree-sign"
      - "org.centos.*.buildsys.tag"

# CENTOS STREAM robosignatory END

# ELN BEGIN

- name: eln queue
  run_once: true
  include_role:
    name: rabbit/queue
  vars:
    username: distrobuildsync-eln
    sent_topics: ^$
    queue_name: distrobuildsync-eln
    # TTL: 10 days (in miliseconds)
    message_ttl: 864000000
    routing_keys:
      - "#.buildsys.repo.done"
      - "#.buildsys.tag"

# ELN END
