1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
From 8db282ed927a1bce6283c3a398a0718ab380bb3c Mon Sep 17 00:00:00 2001
From: Tetja Rediske <tetja@tetja.de>
Date: Wed, 7 Jan 2026 17:41:43 +0100
Subject: [PATCH 1/3] Fixes Parsing for ClearLinux exposed by Gentoo changing
os-release Quoting from " to ', also fixes NA parsing to strip booth kind of
quotes
---
lib/ansible/module_utils/facts/system/distribution.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py
index aeb78d789bff5c..68ffae2a6bd963 100644
--- a/lib/ansible/module_utils/facts/system/distribution.py
+++ b/lib/ansible/module_utils/facts/system/distribution.py
@@ -438,10 +438,10 @@ def parse_distribution_file_NA(self, name, data, path, collected_facts):
for line in data.splitlines():
distribution = re.search("^NAME=(.*)", line)
if distribution and name == 'NA':
- na_facts['distribution'] = distribution.group(1).strip('"')
+ na_facts['distribution'] = distribution.group(1).strip('"').strip("'")
version = re.search("^VERSION=(.*)", line)
if version and collected_facts['distribution_version'] == 'NA':
- na_facts['distribution_version'] = version.group(1).strip('"')
+ na_facts['distribution_version'] = version.group(1).strip('"').strip("'")
return True, na_facts
def parse_distribution_file_Coreos(self, name, data, path, collected_facts):
@@ -489,6 +489,8 @@ def parse_distribution_file_ClearLinux(self, name, data, path, collected_facts):
if 'Clear Linux' not in pname.groups()[0]:
return False, clear_facts
clear_facts['distribution'] = pname.groups()[0]
+ else:
+ return False, clear_facts
version = re.search('VERSION_ID=(.*)', data)
if version:
clear_facts['distribution_major_version'] = version.groups()[0]
From 7ff5b15eddfecf4f47878a09c183af9964028689 Mon Sep 17 00:00:00 2001
From: Tetja Rediske <tetja@tetja.de>
Date: Fri, 9 Jan 2026 22:53:44 +0100
Subject: [PATCH 2/3] Added Gentoo Test Information Added Changelog Fragment
---
.../fragments/clearlinux-gentoo-parsing.yml | 3 ++
.../module_utils/facts/system/distribution.py | 4 +-
.../system/distribution/fixtures/gentoo.json | 47 +++++++++++++++++++
3 files changed, 52 insertions(+), 2 deletions(-)
create mode 100644 changelogs/fragments/clearlinux-gentoo-parsing.yml
create mode 100644 test/units/module_utils/facts/system/distribution/fixtures/gentoo.json
diff --git a/changelogs/fragments/clearlinux-gentoo-parsing.yml b/changelogs/fragments/clearlinux-gentoo-parsing.yml
new file mode 100644
index 00000000000000..7cf73a94e8210f
--- /dev/null
+++ b/changelogs/fragments/clearlinux-gentoo-parsing.yml
@@ -0,0 +1,3 @@
+bugfixes:
+ - 'ansible_facts[os_*] - Contained wrong information, if ClearLinux parsing was tried before falling back to general os-release parsing'
+
diff --git a/lib/ansible/module_utils/facts/system/distribution.py b/lib/ansible/module_utils/facts/system/distribution.py
index 68ffae2a6bd963..ee32605e4291e5 100644
--- a/lib/ansible/module_utils/facts/system/distribution.py
+++ b/lib/ansible/module_utils/facts/system/distribution.py
@@ -438,10 +438,10 @@ def parse_distribution_file_NA(self, name, data, path, collected_facts):
for line in data.splitlines():
distribution = re.search("^NAME=(.*)", line)
if distribution and name == 'NA':
- na_facts['distribution'] = distribution.group(1).strip('"').strip("'")
+ na_facts['distribution'] = distribution.group(1).strip(DistributionFiles.STRIP_QUOTES)
version = re.search("^VERSION=(.*)", line)
if version and collected_facts['distribution_version'] == 'NA':
- na_facts['distribution_version'] = version.group(1).strip('"').strip("'")
+ na_facts['distribution_version'] = version.group(1).strip(DistributionFiles.STRIP_QUOTES)
return True, na_facts
def parse_distribution_file_Coreos(self, name, data, path, collected_facts):
diff --git a/test/units/module_utils/facts/system/distribution/fixtures/gentoo.json b/test/units/module_utils/facts/system/distribution/fixtures/gentoo.json
new file mode 100644
index 00000000000000..759e8651f89e26
--- /dev/null
+++ b/test/units/module_utils/facts/system/distribution/fixtures/gentoo.json
@@ -0,0 +1,47 @@
+{
+ "name": "Gentoo 2.18",
+ "distro": {
+ "codename": "n/a",
+ "id": "gentoo",
+ "name": "Gentoo",
+ "version": "2.18",
+ "version_best": "2.18",
+ "lsb_release_info": {
+ "lsb_version": "n/a",
+ "distributor_id": "Gentoo",
+ "description": "Gentoo Linux",
+ "release": "2.18",
+ "codename": "n/a"
+ },
+ "os_release_info": {
+ "name": "Gentoo",
+ "id": "gentoo",
+ "pretty_name": "Gentoo Linux",
+ "version": "2.18",
+ "version_id": "2.18",
+ "home_url": "https://www.gentoo.org/",
+ "support_url": "https://www.gentoo.org/support/",
+ "bug_report_url": "https://bugs.gentoo.org/",
+ "ansi_color": "1;32"
+ }
+ },
+ "input": {
+ "/etc/os-release": "NAME='Gentoo'\nID='gentoo'\nPRETTY_NAME='Gentoo Linux'\nVERSION='2.18'\nVERSION_ID='2.18'\nHOME_URL='https://www.gentoo.org/'\nSUPPORT_URL='https://www.gentoo.org/support/'\nBUG_REPORT_URL='https://bugs.gentoo.org/'\nANSI_COLOR='1;32'\n",
+ "/etc/gentoo-release": "Gentoo Base System release 2.18\n",
+ "/etc/lsb-release": "DISTRIB_ID=\"Gentoo\"\n",
+ "/usr/lib/os-release": "NAME='Gentoo'\nID='gentoo'\nPRETTY_NAME='Gentoo Linux'\nVERSION='2.18'\nVERSION_ID='2.18'\nHOME_URL='https://www.gentoo.org/'\nSUPPORT_URL='https://www.gentoo.org/support/'\nBUG_REPORT_URL='https://bugs.gentoo.org/'\nANSI_COLOR='1;32'\n"
+ },
+ "platform.dist": [
+ "gentoo",
+ "2.18",
+ "n/a"
+ ],
+ "result": {
+ "distribution": "Gentoo",
+ "distribution_version": "2.18",
+ "distribution_release": "n/a",
+ "distribution_major_version": "2",
+ "os_family": "Gentoo"
+ },
+ "platform.release": "6.18.2-p1-gentoo-dist"
+}
From 8100c7719251c431c87ab94b3945f5fa6b8ff03f Mon Sep 17 00:00:00 2001
From: Tetja Rediske <tetja@tetja.de>
Date: Fri, 9 Jan 2026 23:38:33 +0100
Subject: [PATCH 3/3] removed empty line
---
changelogs/fragments/clearlinux-gentoo-parsing.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/changelogs/fragments/clearlinux-gentoo-parsing.yml b/changelogs/fragments/clearlinux-gentoo-parsing.yml
index 7cf73a94e8210f..3216991aa59012 100644
--- a/changelogs/fragments/clearlinux-gentoo-parsing.yml
+++ b/changelogs/fragments/clearlinux-gentoo-parsing.yml
@@ -1,3 +1,2 @@
bugfixes:
- 'ansible_facts[os_*] - Contained wrong information, if ClearLinux parsing was tried before falling back to general os-release parsing'
-
|