# SPDX-License-Identifier: MIT
---
# yamllint disable rule:line-length
- name: Set platform/version specific variables
  include_vars: "{{ item }}"
  loop:
    - "{{ role_path }}/vars/default.yml"
    - "{{ role_path }}/vars/{{ ansible_facts['os_family'] }}.yml"
    - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}.yml"
    - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}.yml"
    - "{{ role_path }}/vars/{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_version'] }}.yml"
  when: item is file
# yamllint enable rule:line-length

- name: Ensure PCP package repository is configured for RPMs
  template:
    src: packagecloud.rpms.j2
    dest: /etc/yum.repos.d/performancecopilot.repo
    mode: "0600"
  when:
    - ansible_facts['os_family'] == 'RedHat'

- name: Ensure PCP package repository is configured for DEBs
  file:
    src: packagecloud.debs.j2
    dest: /etc/apt/sources.list.d/performancecopilot.sources
    mode: "0600"
  when:
    - ansible_facts['os_family'] == 'Debian'
