Wonders of puppet world

Hello

You may know this but at least for me to archive I find this mail useful. There
are different results for lookupvar of undefined parameter in puppet 2.6, 2.7
and 3. In puppet 2.6 by default you receive empty string, in 2.7 you got
:undefined symbol and in 3 you get nil.

Luckily you can imitate 2.7 behavior in 2.6 by passing second argument to
lookupvar like this, lookupvar('something', false). But be careful since in
2.7 and 3 a second argument is expected to be a hash.

I ended up with following workaround:

options = Puppet::PUPPETVERSION =~ /\A2.6.*/ ? false : {}
lookupvar(arg, options)

Here are some links to see lookupvar in 2.6 [1] 2.7 [2] and 3.1 [3] and 3.2
[4]

[1]https://github.com/puppetlabs/puppet/blob/2.6.x/lib/puppet/parser/scope.rb#L238
[2]https://github.com/puppetlabs/puppet/blob/2.7.x/lib/puppet/parser/scope.rb#L227
[3]https://github.com/puppetlabs/puppet/blob/2.7.x/lib/puppet/parser/scope.rb#L227
[4]https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/parser/scope.rb#L268

··· -- Marek

Excellent time to listen

"We can laugh, until you cry;"

Thanks for the write-up.

LZ

··· On Tue, Sep 10, 2013 at 05:51:25PM +0200, Marek Hulan wrote: > Hello > > You may know this but at least for me to archive I find this mail useful. There > are different results for lookupvar of undefined parameter in puppet 2.6, 2.7 > and 3. In puppet 2.6 by default you receive empty string, in 2.7 you got > :undefined symbol and in 3 you get nil. > > Luckily you can imitate 2.7 behavior in 2.6 by passing second argument to > lookupvar like this, lookupvar('something', false). But be careful since in > 2.7 and 3 a second argument is expected to be a hash. > > I ended up with following workaround: > > options = Puppet::PUPPETVERSION =~ /\A2\.6.*/ ? false : {} > lookupvar(arg, options) > > Here are some links to see lookupvar in 2.6 [1] 2.7 [2] and 3.1 [3] and 3.2 > [4] > > [1]https://github.com/puppetlabs/puppet/blob/2.6.x/lib/puppet/parser/scope.rb#L238 > [2]https://github.com/puppetlabs/puppet/blob/2.7.x/lib/puppet/parser/scope.rb#L227 > [3]https://github.com/puppetlabs/puppet/blob/2.7.x/lib/puppet/parser/scope.rb#L227 > [4]https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/parser/scope.rb#L268 > > -- > Marek > > -- > You received this message because you are subscribed to the Google Groups "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.


Later,

Lukas “lzap” Zapletal
irc: lzap #theforeman

If you like that, I can recommend watching DSL Quest: A WAT Safari1.

··· On Mon, Sep 16, 2013 at 03:05:28PM +0200, Lukas Zapletal wrote: > Excellent time to listen > > http://www.youtube.com/watch?v=ObHm1dLuWWs > > "We can laugh, until you cry;" > > Thanks for the write-up. > > LZ > > On Tue, Sep 10, 2013 at 05:51:25PM +0200, Marek Hulan wrote: > > Hello > > > > You may know this but at least for me to archive I find this mail useful. There > > are different results for lookupvar of undefined parameter in puppet 2.6, 2.7 > > and 3. In puppet 2.6 by default you receive empty string, in 2.7 you got > > :undefined symbol and in 3 you get nil. > > > > Luckily you can imitate 2.7 behavior in 2.6 by passing second argument to > > lookupvar like this, lookupvar('something', false). But be careful since in > > 2.7 and 3 a second argument is expected to be a hash. > > > > I ended up with following workaround: > > > > options = Puppet::PUPPETVERSION =~ /\A2\.6.*/ ? false : {} > > lookupvar(arg, options) > > > > Here are some links to see lookupvar in 2.6 [1] 2.7 [2] and 3.1 [3] and 3.2 > > [4] > > > > [1]https://github.com/puppetlabs/puppet/blob/2.6.x/lib/puppet/parser/scope.rb#L238 > > [2]https://github.com/puppetlabs/puppet/blob/2.7.x/lib/puppet/parser/scope.rb#L227 > > [3]https://github.com/puppetlabs/puppet/blob/2.7.x/lib/puppet/parser/scope.rb#L227 > > [4]https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/parser/scope.rb#L268 > > > > -- > > Marek > > > > -- > > You received this message because you are subscribed to the Google Groups "foreman-dev" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com. > > For more options, visit https://groups.google.com/groups/opt_out. > > -- > Later, > > Lukas "lzap" Zapletal > irc: lzap #theforeman > > -- > You received this message because you are subscribed to the Google Groups "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.