简体   繁体   English

木偶打印资源的所有属性

[英]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" 在这种情况下,“名称,说明,大小,快照保留”

哈希(资源)是我想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM