---
- name: Set rpm version to configure if openshift_pkg_version specified
  set_fact:
    # Expects a leading "-" in inventory, strip it off here, and remove trailing release,
    openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}"
  when:
  - openshift_pkg_version is defined
  - openshift_version is not defined

- block:
  - name: Get available {{ openshift.common.service_type}} version
    repoquery:
      name: "{{ openshift.common.service_type}}"
      ignore_excluders: true
    register: rpm_results

  - fail:
      msg: "Package {{ openshift.common.service_type}} not found"
    when: not rpm_results.results.package_found

  - set_fact:
      openshift_version: "{{ rpm_results.results.versions.available_versions.0 | default('0.0', True) }}"
  when:
  - openshift_version is not defined
