Matthias Saou
2013-Apr-17 17:09 UTC
[Puppet Users] Puppet 3.1, Hiera and a class parameter called "service"
Hi,
I''m trying to clean up some manifests by moving class parameters which
I change globally to Hiera lookups.
I''ve been fighting with a boolean parameter for the last hour. My class
has a parameter called $service, to enable/disable its service (duh!).
When I try to set "mymodule::service: false" from Hiera, it''s
ignored
for some reason, and the $service variable inside mymodule is always
"true", because that''s the default.
If I pass a string, it gets across just fine. I just can''t get the one
useful value, which is the boolean opposite of the default...
Other variable names don''t seem to have this problem. It seems that
I''ve been bitten once more by
"mostly-working-but-reserved-somewhere"
variable names.
Does anyone know Hiera internals enough to confirm this?
Do I have any options other than renaming the parameter?
Matthias
--
Matthias Saou ██ ██
██ ██
Web: http://matthias.saou.eu/ ██████████████
Mail/XMPP: matthias@saou.eu ████ ██████ ████
██████████████████████
GPG: 4096R/E755CC63 ██ ██████████████ ██
8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██
21A9 7A51 7B82 E755 CC63 ████ ████
--
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.
Keith Burdis
2013-Apr-17 17:18 UTC
Re: [Puppet Users] Puppet 3.1, Hiera and a class parameter called "service"
Perhaps try using the str2bool function from puppetlabs-stdlib [1]. - Keith [1] https://github.com/puppetlabs/puppetlabs-stdlib On 17 Apr 2013 18:09, "Matthias Saou" <matthias@saou.eu> wrote:> Hi, > > I''m trying to clean up some manifests by moving class parameters which > I change globally to Hiera lookups. > > I''ve been fighting with a boolean parameter for the last hour. My class > has a parameter called $service, to enable/disable its service (duh!). > > When I try to set "mymodule::service: false" from Hiera, it''s ignored > for some reason, and the $service variable inside mymodule is always > "true", because that''s the default. > > If I pass a string, it gets across just fine. I just can''t get the one > useful value, which is the boolean opposite of the default... > > Other variable names don''t seem to have this problem. It seems that > I''ve been bitten once more by "mostly-working-but-reserved-somewhere" > variable names. > > Does anyone know Hiera internals enough to confirm this? > > Do I have any options other than renaming the parameter? > > Matthias > > -- > Matthias Saou ██ ██ > ██ ██ > Web: http://matthias.saou.eu/ ██████████████ > Mail/XMPP: matthias@saou.eu ████ ██████ ████ > ██████████████████████ > GPG: 4096R/E755CC63 ██ ██████████████ ██ > 8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██ > 21A9 7A51 7B82 E755 CC63 ████ ████ > > -- > 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. > > >-- 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.
Nick Fagerlund
2013-Apr-17 21:27 UTC
[Puppet Users] Re: Puppet 3.1, Hiera and a class parameter called "service"
Hey Matthias! It''s a Puppet bug. Sorry.
http://projects.puppetlabs.com/issues/17474
It''s fixed in 3.2, which isn''t quite out yet -- 3.2.0-rc1 is
probably
coming out this week.
In the meantime, Keith is right:
- Put quotes around "false" in your Hiera yaml files.
- In your Puppet code, put a line like:
$service_real = str2bool("$service")
I''ve been calling that pattern "sloppy bools." It will work
around the bug
for now, and continue to work once the bug is fixed and you start using
real booleans in your yaml again.
On Wednesday, April 17, 2013 10:09:30 AM UTC-7, Matthias Saou
wrote:>
> Hi,
>
> I''m trying to clean up some manifests by moving class parameters
which
> I change globally to Hiera lookups.
>
> I''ve been fighting with a boolean parameter for the last hour. My
class
> has a parameter called $service, to enable/disable its service (duh!).
>
> When I try to set "mymodule::service: false" from Hiera,
it''s ignored
> for some reason, and the $service variable inside mymodule is always
> "true", because that''s the default.
>
> If I pass a string, it gets across just fine. I just can''t get the
one
> useful value, which is the boolean opposite of the default...
>
> Other variable names don''t seem to have this problem. It seems
that
> I''ve been bitten once more by
"mostly-working-but-reserved-somewhere"
> variable names.
>
> Does anyone know Hiera internals enough to confirm this?
>
> Do I have any options other than renaming the parameter?
>
> Matthias
>
> --
> Matthias Saou ██ ██
> ██ ██
> Web: http://matthias.saou.eu/ ██████████████
> Mail/XMPP: matt...@saou.eu <javascript:> ████ ██████
████
> ██████████████████████
> GPG: 4096R/E755CC63 ██ ██████████████ ██
> 8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██
> 21A9 7A51 7B82 E755 CC63 ████ ████
>
--
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.
Matthias Saou
2013-Apr-18 08:12 UTC
Re: [Puppet Users] Re: Puppet 3.1, Hiera and a class parameter called "service"
Thanks for the bug report link!
I''ll definitely be eagerly waiting for 3.2, and will try the RC for
sure. In the meantime, even using the quoted "false" means that
I''ll
need to adapt my classes, since I''m doing simple existence/bool checks
:
if $service { ... }
So when $service is the "false" string, the condition is still true.
But I don''t mind modifying to "if $service == true" since
it''s not any
dirtier.
Matthias
On Wed, 17 Apr 2013 14:27:20 -0700 (PDT)
Nick Fagerlund <nick.fagerlund@puppetlabs.com> wrote:
> Hey Matthias! It''s a Puppet bug. Sorry.
> http://projects.puppetlabs.com/issues/17474
>
> It''s fixed in 3.2, which isn''t quite out yet -- 3.2.0-rc1
is probably
> coming out this week.
>
> In the meantime, Keith is right:
>
> - Put quotes around "false" in your Hiera yaml files.
> - In your Puppet code, put a line like:
>
> $service_real = str2bool("$service")
>
> I''ve been calling that pattern "sloppy bools." It will
work around
> the bug for now, and continue to work once the bug is fixed and you
> start using real booleans in your yaml again.
>
> On Wednesday, April 17, 2013 10:09:30 AM UTC-7, Matthias Saou wrote:
> >
> > Hi,
> >
> > I''m trying to clean up some manifests by moving class
parameters
> > which I change globally to Hiera lookups.
> >
> > I''ve been fighting with a boolean parameter for the last
hour. My
> > class has a parameter called $service, to enable/disable its
> > service (duh!).
> >
> > When I try to set "mymodule::service: false" from Hiera,
it''s
> > ignored for some reason, and the $service variable inside mymodule
> > is always "true", because that''s the default.
> >
> > If I pass a string, it gets across just fine. I just can''t
get the
> > one useful value, which is the boolean opposite of the default...
> >
> > Other variable names don''t seem to have this problem. It
seems that
> > I''ve been bitten once more by
> > "mostly-working-but-reserved-somewhere" variable names.
> >
> > Does anyone know Hiera internals enough to confirm this?
> >
> > Do I have any options other than renaming the parameter?
> >
> > Matthias
> >
> > --
> > Matthias Saou ██ ██
> > ██ ██
> > Web: http://matthias.saou.eu/ ██████████████
> > Mail/XMPP: matt...@saou.eu <javascript:> ████
██████
> > ████ ██████████████████████
> > GPG: 4096R/E755CC63 ██ ██████████████ ██
> > 8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██
> > 21A9 7A51 7B82 E755 CC63 ████ ████
> >
>
--
Matthias Saou ██ ██
██ ██
Web: http://matthias.saou.eu/ ██████████████
Mail/XMPP: matthias@saou.eu ████ ██████ ████
██████████████████████
GPG: 4096R/E755CC63 ██ ██████████████ ██
8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██
21A9 7A51 7B82 E755 CC63 ████ ████
--
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.
Calvin Walton
2013-Apr-19 00:51 UTC
Re: [Puppet Users] Re: Puppet 3.1, Hiera and a class parameter called "service"
On Wed, 2013-04-17 at 14:27 -0700, Nick Fagerlund wrote:> Hey Matthias! It''s a Puppet bug. Sorry. > http://projects.puppetlabs.com/issues/17474 > > It''s fixed in 3.2, which isn''t quite out yet -- 3.2.0-rc1 is probably > coming out this week. > > In the meantime, Keith is right: > > - Put quotes around "false" in your Hiera yaml files. > - In your Puppet code, put a line like: > > $service_real = str2bool("$service") > > I''ve been calling that pattern "sloppy bools." It will work around the bug > for now, and continue to work once the bug is fixed and you start using > real booleans in your yaml again.The other workaround is to change your class definition from class foo ( $bar = true ) { ... } to class foo ( $bar = hiera(''foo::bar'', true) ) { ... } since the ''hiera'' function does not suffer from this bug. This requires no changes to your yaml file or elsewhere in the code, and can be removed once you upgrade to a puppet version that includes the fix. -- Calvin Walton <calvin.walton@kepstin.ca> -- 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.
ForumUser
2013-Apr-22 15:20 UTC
Re: [Puppet Users] Re: Puppet 3.1, Hiera and a class parameter called "service"
Hello,
I also perhaps faced the bug. I am trying to workaround it:
common.yaml
accounts::users::accounts:
user_1:
ensure: present
home: /home/user_1
managehome: "true"
shell: /bin/bash
uid: 4018
gid: group1
$mh = str2bool ("$accounts::users::accounts::managehome") # <- I
am not
sure if I get it correctly ?
define create_user ($uid, $gid, $ensure = present, $home =
"/home/$name",
$shell = "/bin/bash", $managehome = $mh )
{
user { $name:
uid => $uid,
gid => $gid,
}
...
Am I using the correct syntax to get the correct value ?
--
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.