Using undef in a class declaration... appears to be the subject of a bunch of documents I am ill-qualified to interpret.
https://docs.puppetlabs.com/puppet/latest/reference/lang_data_undef.html "Puppet’s special undef value is roughly equivalent to nil in Ruby; it represents the absence of a value", implying that using undef in a class parameter is like not having that class parameter in the first place. I thought of hiera because when hiera returns nil it is interpreted as "value not present" per that thread. https://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html#overriding-resource-attributes https://projects.puppetlabs.com/issues/16221 So yes, absolutely doesn't work. On Tue, Oct 27, 2015 at 12:07:26PM +0100, DEGREMONT Aurelien wrote: > Le 27/10/2015 11:12, Christopher Wood a écrit : > >Unless there have been any developments of which I am unaware, you would > >need to handle this in the code+hiera. Here's where I dribbled all over this > >thing a few months ago: > > > >https://groups.google.com/forum/#!msg/puppet-users/0l3m4VCHjOg/KKlz5LNpCgYJ > > I think it is different. In my example, there is no hiera involved. > My problem is : > I want my class param value to be 'undef', and not it being 'use the default > value' > > There is no way to set a class param value to undef if there is default > value for it different from undef. > > Thanks anyway > > > > >On Tue, Oct 27, 2015 at 10:03:19AM +0100, DEGREMONT Aurelien wrote: > >>Hello > >> > >>When using class parameters I often face the same issue regarding undef > >>usage. > >>Let's say I got this simple class: > >> > >>class foo ( > >> $service_ensure = 'running', > >>) { > >> service { 'foo': > >> ensure => $service_ensure; > >> } > >>} > >> > >> > >>include foo # will set the service running > >> > >> > >>class { 'foo': > >> service_ensure => 'stopped'; # will set the service stopped > >>} > >> > >> > >>And now, I would like to say 'do not care about ensure'. Do not touch it. > >>For that, I need that ensure is set to 'undef' > >> > >>But I cannot use: > >> > >>class { 'foo': > >> service_ensure => undef; > >>} > >> > >>because in this case, Puppet will use the default value of the parameter, in > >>this case: running. > >> > >>I have this problem for a lot of different modules and I looking for a > >>simple way to do this. > >>I would like to avoid adding an if/else in all my classes. > >> > >> > >>Thanks in advance > >> > >>Aurélien > >> > >>-- > >>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 [email protected]. > >>To view this discussion on the web visit > >>https://groups.google.com/d/msgid/puppet-users/562F3DD7.8010008%40cea.fr. > >>For more options, visit https://groups.google.com/d/optout. > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/562F5AEE.8040007%40cea.fr. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20151027131434.GA19540%40iniquitous.heresiarch.ca. For more options, visit https://groups.google.com/d/optout.
