[facts] fix version facts on FreeBSD RC/PRERELEASE (#73020)

Change:
- The FreeBSD release can contain -RC or -PRERELEASE in addition to
  -RELEASE, -STABLE, or -CURRENT.

Test Plan:
- Added new fixed from an RC version of TrueNAS which uses a -PRERELEASE
  version of FreeBSD.

Tickets:
- Fixes #72331

Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Rick Elrod 2021-01-05 09:16:59 -06:00 committed by GitHub
parent 003a9e890d
commit 20509b6507
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- distribution facts - Allow ``distribution_major_version`` and ``distribution_version`` to work for RC and PRERELEASE versions of FreeBSD (and derived distributions) (https://github.com/ansible/ansible/issues/72331).

View file

@ -586,7 +586,7 @@ class Distribution(object):
def get_distribution_FreeBSD(self):
freebsd_facts = {}
freebsd_facts['distribution_release'] = platform.release()
data = re.search(r'(\d+)\.(\d+)-(RELEASE|STABLE|CURRENT).*', freebsd_facts['distribution_release'])
data = re.search(r'(\d+)\.(\d+)-(RELEASE|STABLE|CURRENT|RC|PRERELEASE).*', freebsd_facts['distribution_release'])
if 'trueos' in platform.version():
freebsd_facts['distribution'] = 'TrueOS'
if data:

View file

@ -0,0 +1,39 @@
{
"name": "FreeBSD 12.2",
"distro": {
"codename": "",
"id": "freebsd",
"name": "FreeBSD",
"version": "12.2",
"version_best": "12.2",
"lsb_release_info": {},
"os_release_info": {
"name": "FreeBSD",
"version": "12.2-PRERELEASE",
"version_id": "12.2",
"id": "freebsd",
"ansi_color": "0;31",
"pretty_name": "FreeBSD 12.2-PRERELEASE",
"cpe_name": "cpe:/o:freebsd:freebsd:12.2",
"home_url": "https://FreeBSD.org/",
"bug_report_url": "https://bugs.FreeBSD.org/"
}
},
"input": {
"/etc/os-release": "NAME=FreeBSD\nVERSION=12.2-PRERELEASE\nVERSION_ID=12.2\nID=freebsd\nANSI_COLOR=\"0;31\"\nPRETTY_NAME=\"FreeBSD 12.2-PRERELEASE\"\nCPE_NAME=cpe:/o:freebsd:freebsd:12.2\nHOME_URL=https://FreeBSD.org/\nBUG_REPORT_URL=https://bugs.FreeBSD.org/\n"
},
"platform.dist": [
"freebsd",
"12.2",
""
],
"result": {
"distribution": "FreeBSD",
"distribution_version": "12.2",
"distribution_release": "12.2-PRERELEASE",
"distribution_major_version": "12",
"os_family": "FreeBSD"
},
"platform.system": "FreeBSD",
"platform.release": "12.2-PRERELEASE"
}