Array of properties matching_all not working

23 views
Skip to first unread message

Lupin Deterd

unread,
Dec 4, 2016, 3:27:55 AM12/4/16
to puppet...@googlegroups.com
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

Stefan Schulte

unread,
Dec 5, 2016, 4:05:52 AM12/5/16
to puppet...@googlegroups.com


On 04.12.2016 09:27, Lupin Deterd wrote:
> 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

I think this should read

:array_matching => :all

instead of

:array => :matching_all

- Stefan

Lupin Deterd

unread,
Dec 6, 2016, 1:22:45 AM12/6/16
to puppet...@googlegroups.com
Spot on. Thank you very much.


- Stefan

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/67a5b890-9fbc-9d94-dfa8-92b3ad1c05a2%40posteo.de.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages