Hi,
I'm working on a custom type & provider. One of the property is an Array and I want to match every elements in it but somehow I can't make it work. Relevant snippet are as follow:
type/zfsacl.rb
newproperty(:permission, :array => :matching_all) do
desc "Array of ZFS ACL permissions"
def insync?(is)
Puppet.debug("#@resource[:name]}: Property :permission -> is: #{is}")
Puppet.debug("#@resource[:name]}: Property :permission -> is: #{should}")
if is.is_a?(Array) and @should.is_a?(Array)
is.sort == @should.sort
else
is.sort == @should
end
end
end
#End of permission property
provider/zfsacl/zfs.rb
def permission
return [] unless File.exists?(resource[:path])
value = []
ls('-Vd', resource[:path]).split("\n").each do |line|
if (line =~ /^(user)|(group):/)
value << line
end
end
value.empty? ? [] : value.sort
end
def permission=(value)
Puppet.debug "Running: #{resource[:action]} with #{value}"
value = value - permission
case resource[:action]
when :unset
unset
Puppet.debug "Running: #{resource[:action]}"
when :set
Puppet.debug "Running: #{resource[:action]}"
value.each do |perm|
set_perm(perm, resource[:path])
end
end
end
My manifest definition looks like this:
zfsacl { '/transfer/ax/out':
action => 'set',
permission => [ 'wasuser:rw:f:allow',
'wasgroup:d:allow',
'wasuser:rwx:f:allow',
]
}
And the error I'm getting is:
Info: Applying configuration version '1480846888'
Debug: Zfsacl[/transfer/ax/out][:name]}: Property :permission -> is: []
Debug: Zfsacl[/transfer/ax/out][:name]}: Property :permission -> is: wasuser:rw:f:allow
Debug: Running: set with wasuser:rw:f:allow
Debug: Running: set
Debug: Running: set with wasuser:rw:f:allow
Error: undefined method `each' for "wasuser:rw:f:allow":String
Error: /Stage[main]/Zfsacl/Zfsacl[/transfer/ax/out]/permission: change from [] to wasuser:rw:f:allow failed: undefined method `each' for "wasuser:rw:f:allow":String
Debug: Finishing transaction 5598240
Why isn't the `should` property is turned into a single String instead of an Array of Strings? I'm running Puppet on Solaris x86.
Publisher: solaris
Version: 3.6.2
Build Release: 5.11
Branch: 0.175.3.0.0.30.0
Thanks in advance for any pointers/help,
Lupin