diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-11-06 14:14:05 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-11-06 14:14:05 -0800 |
commit | 4b865541b6142f0c9f01d802cfe19c774ef23389 (patch) | |
tree | bc0b6d2eed8c184a8ebc36cc3e2d578f6159369c | |
parent | aa92dad7759aa21fb13029a195ba26fb3f7ffc62 (diff) | |
download | ohai-4b865541b6142f0c9f01d802cfe19c774ef23389.tar.gz |
Fix parsing of hostnamectl to support values with colonsfix_hostnamectl
This is probably faster too since we don't have to lstrip each result.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/linux/hostnamectl.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/linux/hostnamectl_spec.rb | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/ohai/plugins/linux/hostnamectl.rb b/lib/ohai/plugins/linux/hostnamectl.rb index fb718e98..b117963f 100644 --- a/lib/ohai/plugins/linux/hostnamectl.rb +++ b/lib/ohai/plugins/linux/hostnamectl.rb @@ -26,8 +26,8 @@ Ohai.plugin(:Hostnamectl) do hostnamectl_path = which("hostnamectl") if hostnamectl_path shell_out(hostnamectl_path).stdout.split("\n").each do |line| - key, val = line.split(":") - hostnamectl[key.chomp.lstrip.tr(" ", "_").downcase] = val.chomp.lstrip + key, val = line.split(": ") + hostnamectl[key.chomp.lstrip.tr(" ", "_").downcase] = val.chomp end end end diff --git a/spec/unit/plugins/linux/hostnamectl_spec.rb b/spec/unit/plugins/linux/hostnamectl_spec.rb index 5dd7e052..3994f4ab 100644 --- a/spec/unit/plugins/linux/hostnamectl_spec.rb +++ b/spec/unit/plugins/linux/hostnamectl_spec.rb @@ -34,6 +34,7 @@ describe Ohai::System, "Linux hostnamectl plugin" do Boot ID: e085ae9e65e245a8a7b62912adeebe97 Operating System: Debian GNU/Linux 8 (jessie) Kernel: Linux 4.3.0-0.bpo.1-amd64 + CPE OS Name: cpe:/o:foo:bar:8 Architecture: x86-64 HOSTNAMECTL_OUT @@ -44,6 +45,7 @@ describe Ohai::System, "Linux hostnamectl plugin" do "static_hostname" => "foo", "icon_name" => "computer-laptop", "chassis" => "laptop", + "cpe_os_name" => "cpe:/o:foo:bar:8", "machine_id" => "6f702523e2fc7499eb1dc68e5314dacf", "boot_id" => "e085ae9e65e245a8a7b62912adeebe97", "operating_system" => "Debian GNU/Linux 8 (jessie)", |