Hi, please note that this is a very unusual structure. Properties that are not assigned a desired value will just be left as is by the agent. Upon creating a new resource on the managed system, the *ensure* property can impose a default value.
Are you sure that you want to force the user to supply a property value that Puppet will keep enforcing? If so, your code is almost correct, assuming that :absent is not a valid value for your property. If it is, you may want to pick another default such as :foo. newproperty(:bp) do defaultto do :absent end validate do |value| if value == :absent raise ArgumentError, "'bp' property is mandatory" end end end HTH, Felix On 02/10/2015 11:15 AM, Angel L. Mateo wrote: > Hello, > > I'm trying to create my own custom type according to guide at > http://garylarizza.com/blog/2013/12/15/seriously-what-is-this-provider-doing/. > > > My problem is that I want one of the resource's properties to be > mandatory and failed if the property is not defined. So in the type I > have: > > newproperty(:bp) do > defaultto do :absent end > validate do |value| > raise ArgumentError, "'bp' property is mandatory" > end > end > > With this code, evertyhing seems fine when I'm programming puppet > and if I try to create a resource without a "bp" property, I get the > error message. > > But my problem is that with this code, I can't use "puppet > resource" order, because I get the error too when it tries to get the > list of resources already defined. > > Any help? -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/54F39AA9.2000009%40Alumni.TU-Berlin.de. For more options, visit https://groups.google.com/d/optout.