Puppet 打印资源的所有属性

Puppet print all attributes of a resource

在存在?方法我从远程源获取值。然后我想根据请求的值检查值。我的资源类型是 volume

volume { 'create a volume 1':
  ensure      => present,
  name        => "vol1",
  description => 'This is a volume',
  size        => '100g',
  snap_reserve => 10,
  force       => true,
  transport   => hiera('credentials')
}

在我的存在?方法

def exists?
  $token=getAuthToken(resource[:transport])
  allVolumes = returnAllVolumes(resource[:transport])
  allVolumes.each do |volume|
      if resource[:name].eql? volume["name"]
         # Here I want to compare the value from resource
         return true
      end
  end
  return false      
end

如何打印所有属性?在这种情况下 "name,description,size,snap_reserve"

Hash(resource) 正是我要找的。