Search code examples
rubypuppetpuppet-enterprise

Puppet print all attributes of a resource


In the exists? method I get the value from a remote source. Then I want to check the value against what has been requested. My resource type is 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')
}

In my exist? method

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

How do I print all attributes ? In this case "name,description,size,snap_reserve"


Solution

  • Hash(resource) is what I was looking for.