Hi. I''m having trouble to write a custom type that accepts array as property. This is example of my custom type resource definition: customtype { ''blah'': myarray => [''a'',''b''], } This is what I''ve got in provider: def myarray=(value) require ''pp'' pp value end But pp prints only "a"... It would be really helpful if I could see example of array in custom type... So any help is appreciated. -- Jakov Sosic www.srce.unizg.hr -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Sun, Oct 21, 2012 at 10:04 AM, Jakov Sosic <jsosic@srce.hr> wrote:> I''m having trouble to write a custom type that accepts array as property. > This is example of my custom type resource definition: > > customtype { ''blah'': > myarray => [''a'',''b''], > } > > This is what I''ve got in provider: > > def myarray=(value) > require ''pp'' > pp value > end > > > But pp prints only "a"... It would be really helpful if I could see example > of array in custom type... So any help is appreciated.Puppet::Type.newtype(:customtype) do newproperty(:myarray, array_matching => :all) do end end HTH, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 10/21/2012 10:43 PM, Nan Liu wrote:> Puppet::Type.newtype(:customtype) do > newproperty(:myarray, array_matching => :all) do > end > endThank you! Although you have syntax error, it should be: newproperty(:myarray, :array_matching => :all) do Note the collon in front of array_matching. Also, what I did notice is that this code: newproperty(:nameservers, :array_matching => :all) do desc "list of nameservers" defaultto [] end Doesn''t revert to default if I remove the ''nameservers'' property from my manifest. I had to overload insync? for it to work, and now type looks like this: newproperty(:nameservers, :array_matching => :all) do desc "list of nameservers added to profile" defaultto [] def insync?(is) # if members of arrays are not the same, something # was added or removed from manifest, so return false return false unless is == should true end end Although I don''t get it because I didn''t do anything special in the overloaded insync? :) And without it won''t work. It won''t work even if I set: nameservers => [] in my manifest. But never mind, I got it working so I''m satisfied so far. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Mon, Oct 22, 2012 at 10:53:44PM +0200, Jakov Sosic wrote:> On 10/21/2012 10:43 PM, Nan Liu wrote: > > > Puppet::Type.newtype(:customtype) do > > newproperty(:myarray, array_matching => :all) do > > end > > end > > Thank you! > > Although you have syntax error, it should be: > > newproperty(:myarray, :array_matching => :all) do > > Note the collon in front of array_matching. > > > Also, what I did notice is that this code: > > newproperty(:nameservers, :array_matching => :all) do > desc "list of nameservers" > defaultto [] > end > > Doesn''t revert to default if I remove the ''nameservers'' property from my > manifest. > > I had to overload insync? for it to work, and now type looks like this: > > newproperty(:nameservers, :array_matching => :all) do > desc "list of nameservers added to profile" > defaultto [] > def insync?(is) > # if members of arrays are not the same, something > # was added or removed from manifest, so return false > return false unless is == should > true > end > end > > > Although I don''t get it because I didn''t do anything special in the > overloaded insync? :) And without it won''t work. It won''t work even if I > set: > > nameservers => [] > > in my manifest. > > But never mind, I got it working so I''m satisfied so far.Yeah I also consider this a bug. There is a ticket for the issue though http://projects.puppetlabs.com/issues/10237 -Stefan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 10/23/2012 01:47 AM, Stefan Schulte wrote:> Yeah I also consider this a bug. There is a ticket for the issue though > http://projects.puppetlabs.com/issues/10237Yeah that''s it! I''ve added a link as a comment to my type.rb''s Thank you Stefan! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.