# SPDX-License-Identifier: MIT
---
- name: Get LSR_RHC_TEST_DATA environment variable
  set_fact:
    lsr_rhc_test_data_file: "{{ lookup('env', 'LSR_RHC_TEST_DATA') }}"
  become: false

- name: Handle external lsr_rhc_test_data
  when: lsr_rhc_test_data_file | length > 0
  become: false
  block:
    - name: Import test data
      include_vars:
        file: "{{ lsr_rhc_test_data_file }}"

    - name: Get facts for external test data
      setup:
        gather_subset:
          - "!all"
          - "!min"
          - distribution
          - distribution_major_version

- name: Set local lsr_rhc_test_data
  include_vars:
    file: ../files/candlepin_data.yml
  when: lsr_rhc_test_data_file | length == 0

- name: Determine if system is ostree and set flag
  when: not __rhc_is_ostree is defined
  block:
    - name: Check if system is ostree
      stat:
        path: /run/ostree-booted
      register: __ostree_booted_stat

    - name: Set flag to indicate system is ostree
      set_fact:
        __rhc_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
