summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-02-02 16:19:41 -0800
committerGitHub <noreply@github.com>2021-02-02 16:19:41 -0800
commit51bd6af79e6e662e14e5b9615233afad98b903a6 (patch)
tree0333638464cdaa3b593c5a1028077d778781b08f
parentd175d5189c8dc7bfed4689927fa4c6312fec80c1 (diff)
parentb1c13596a94350f4559540919c66702b334a06d5 (diff)
downloadohai-51bd6af79e6e662e14e5b9615233afad98b903a6.tar.gz
Merge pull request #1613 from michel-slm/platform-version-debian-testing
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/linux/platform.rb3
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb25
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index 4868c070..c5fa98c5 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -287,6 +287,9 @@ Ohai.plugin(:Platform) do
# centos only includes the major version in os-release for some reason
if os_release_info["ID"] == "centos"
get_redhatish_version(file_read("/etc/redhat-release").chomp)
+ # debian testing and unstable don't have VERSION_ID set
+ elsif os_release_info["ID"] == "debian"
+ os_release_info["VERSION_ID"] || file_read("/etc/debian_version").chomp
else
os_release_info["VERSION_ID"] || shell_out("/bin/uname -r").stdout.strip
end
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index 520a5a26..64976b8e 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -312,6 +312,31 @@ describe Ohai::System, "Linux plugin platform" do
expect(plugin[:platform_version]).to eq("7.5.1804")
end
end
+
+ context "when on debian and version data in os-release is missing" do
+ let(:os_data) do
+ <<~OS_DATA
+ PRETTY_NAME="Debian GNU/Linux bullseye/sid"
+ NAME="Debian GNU/Linux"
+ ID=debian
+ HOME_URL="https://www.debian.org/"
+ SUPPORT_URL="https://www.debian.org/support"
+ BUG_REPORT_URL="https://bugs.debian.org/"
+ OS_DATA
+ end
+
+ before do
+ expect(plugin).to receive(:file_read).with("/etc/os-release").and_return(os_data)
+ expect(plugin).to receive(:file_read).with("/etc/debian_version").and_return("bullseye/sid")
+ end
+
+ it "sets platform, platform_family from os-release and platform_version from debian_version" do
+ plugin.run
+ expect(plugin[:platform]).to eq("debian")
+ expect(plugin[:platform_family]).to eq("debian")
+ expect(plugin[:platform_version]).to eq("bullseye/sid")
+ end
+ end
end
context "when on system without /etc/os-release (legacy)" do