parameterized classes broken in 3.0.0rc2?

371 views
Skip to first unread message

Jason Wright

unread,
Aug 15, 2012, 8:54:27 PM8/15/12
to puppet...@googlegroups.com
I was testing parameterized classes using an external node classifier
running on a 3.0.0rc2 master and found that catalog compilation fails
if I have a parameterized class that uses defaults if I declare an
instance of the class that does not specify values for all parameters.
I was able to reproduce the behavior using 'puppet apply':

logos: /tmp ] cat foo.pp
class foo($foo1="default1", $foo2="default2") {
file { "/tmp/foofile":
content => "foo1=\"$foo1\" foo2=\"$foo2\"\n"
}
}

class { "foo":
}

Rather than getting a file with the class default values, catalog
compilation fails:

logos: /tmp ] sudo puppet apply foo.pp
Error: Puppet::Parser::AST::Resource failed with error RuntimeError:
Hiera terminus not supported without hiera library at /tmp/foo.pp:8 on
node logos
Error: Puppet::Parser::AST::Resource failed with error RuntimeError:
Hiera terminus not supported without hiera library at /tmp/foo.pp:8 on
node logos

I get the same error if I declare a value for either one (but not
both) of the parameters but if I declare values for both parameters,
it works as expected:

class { "foo":
foo1 => "value1",
foo2 => "value2",
}

logos: /tmp ] sudo puppet apply foo.pp
/Stage[main]/Foo/File[/tmp/foofile]/ensure: defined content as
'{md5}42bcc1edf4e8ea1f2aeffafe2ef26712'
Finished catalog run in 0.41 seconds
logos: /tmp ] cat /tmp/foofile
foo1="value1" foo2="value2"

This class works fine with 'puppet apply' on all of the 2.7.x nodes
I've tested; I can declare the class with any valid combination of
default and non-default parameter values. It only fails on 3.0.0rc2.

Thanks,
Jason

--
"Life was better when sun4m mattered." -Thom

jcbollinger

unread,
Aug 16, 2012, 9:53:41 AM8/16/12
to puppet...@googlegroups.com


It sounds like you have a broken or incomplete puppet installation.  Hiera is deeply integrated with Puppet 3, and in particular with resolving unspecified class parameters.  It is not an optional third-party library as it was in Puppet 2.x and earlier.  PuppetLabs provides it in a separate package, however, which might lead you to think that you don't need to install it.

That does not mean you have to put anything in a hiera data store, or even configure one (as far as I know), but it needs to be there because in Puppet 3, the master tries to fill in parameter values via hiera before it falls back to default values specified in the class definition.  (That behavior is awesome, btw.)


John

Jason Wright

unread,
Aug 16, 2012, 2:38:03 PM8/16/12
to puppet...@googlegroups.com
On Thu, Aug 16, 2012 at 6:53 AM, jcbollinger <John.Bo...@stjude.org> wrote:
> It sounds like you have a broken or incomplete puppet installation.

You are correct, installing hiera fixed it.
Reply all
Reply to author
Forward
0 new messages