diff --git a/lib/itamae/node.rb b/lib/itamae/node.rb index 88d56486..fde8d760 100644 --- a/lib/itamae/node.rb +++ b/lib/itamae/node.rb @@ -61,7 +61,12 @@ def respond_to?(method, priv = false) end def fetch_inventory_value(key) - @backend.host_inventory[key] + value = @backend.host_inventory[key] + if value.is_a?(Hash) + value = Hashie::Mash.new(value) + end + + value rescue NotImplementedError, NameError nil end diff --git a/spec/integration/recipes/default.rb b/spec/integration/recipes/default.rb index dbbad6c8..5c81ed72 100644 --- a/spec/integration/recipes/default.rb +++ b/spec/integration/recipes/default.rb @@ -335,3 +335,13 @@ end end end + +### + +v1 = node.memory.total +v2 = node[:memory][:total] +v3 = node['memory']['total'] + +unless v1 == v2 && v2 == v3 && v1 =~ /\A\d+kB\z/ + raise "failed to fetch host inventory value (#{v1}, #{v2}, #{v3})" +end