FAQ
Hi.

I seem to have the following problem. This is a code from my custom type:

newproperty(:kernel_options) do
desc "Kernel options for installation boot."
defaultto {}

def insync?(is)
# @should is an Array. see lib/puppet/type.rb insync?
should = @should.first

# if members of hashes are not the same, something
# was added or removed from manifest, so return false
return false unless is.class == Hash and should.class == Hash and
is.keys.sort == should.keys.sort
# check if values of hash keys are equal
is.each do |l,w|
return false unless w == should[l]
end
true
end

def should_to_s(newvalue)
newvalue.inspect
end

def is_to_s(currentvalue)
currentvalue.inspect
end
end



But, if I change the system manually, and if kernel_options property is
not set in my resource, then puppet doesn't change the system back to
it's original values.

So, defaultto seems to be ignored. If I set kernel_options => {}
they are indeed obeyed and applied.


Any ideas why is this the case? defaultto works ok if I don't use the
hash in my property, so I guess it's something to do with the
is_to_s/should_to_s/insync overrides?


--
Jakov Sosic
www.srce.unizg.hr

--
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jcbollinger at Feb 25, 2013 at 2:55 pm
    It looks like you are stumbling over a Ruby syntax ambiguity. The fragment
    "{}" can be either an empty hash or an empty block. Because the
    'defaultto' method can accept a block, Ruby resolves the ambiguity in favor
    of that interpretation. I think it will work better (and also be clearer)
    if you instead write

    defaultto Hash.new



    John

    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jakov Sosic at Mar 4, 2013 at 5:52 pm

    On 02/25/2013 03:55 PM, jcbollinger wrote:

    It looks like you are stumbling over a Ruby syntax ambiguity. The
    fragment "{}" can be either an empty hash or an empty block. Because
    the 'defaultto' method can accept a block, Ruby resolves the ambiguity
    in favor of that interpretation. I think it will work better (and also
    be clearer) if you instead write

    defaultto Hash.new

    Thank you, that did it! Really an ambiguity... :)

    --
    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 post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedFeb 25, '13 at 12:25a
activeMar 4, '13 at 5:52p
posts3
users2
websitepuppetlabs.com

2 users in discussion

Jakov Sosic: 2 posts Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase