---
- name: Check for /etc/rhosp-release
  stat:
      path: "/etc/rhosp-release"
  register: rhosp_release_file

- name: Get /etc/rhosp-release content
  command: cat /etc/rhosp-release
  register: rhosp_release_content
  when: rhosp_release_file.stat.exists

- name: Set overcloud_version from /etc/rhosp-release output
  set_fact:
      undercloud_version: "{{ rhosp_release_content.stdout | regex_replace('^Red Hat OpenStack Platform release ([0-9]+)\\.\\d+\\s.*$', '\\1') }}"
      overcloud_version: "{{ rhosp_release_content.stdout | regex_replace('^Red Hat OpenStack Platform release ([0-9]+)\\.\\d+\\s.*$', '\\1') }}"
  when: rhosp_release_file.stat.exists

---
- name: Check for /etc/rhosp-release
  stat:
      path: "/etc/rhosp-release"
  register: rhosp_release_file

- name: Get /etc/rhosp-release content
  command: cat /etc/rhosp-release
  register: rhosp_release_content
  when: rhosp_release_file.stat.exists

- name: Set overcloud_version from /etc/rhosp-release output
  set_fact:
      undercloud_version: "{{ rhosp_release_content.stdout | regex_replace('^Red Hat OpenStack Platform release ([0-9]+)\\.\\d+.*', '\\1') }}"
      overcloud_version: "{{ rhosp_release_content.stdout | regex_replace('^Red Hat OpenStack Platform release ([0-9]+)\\.\\d+.*', '\\1') }}"
  when: rhosp_release_file.stat.exists

Make /etc/rhosp-release regexp more flexible
Make /etc/rhosp-release regexp more flexible

In version-discovery method based on /etc/rhosp-release
regexp used for parsing version is very strict,
but now also maintenance version can be present there.

Lets make it more flexible by detecting juts beginning of these lines.

Related to https://bugzilla.redhat.com/show_bug.cgi?id=1640291

Change-Id: If63f38aee6ae1f5c6309303844bf8aa8ddb1f7e1
