Skip to content

Commit

Permalink
LP: Update class parameters chapter with PE 3+ info
Browse files Browse the repository at this point in the history
This update got orphaned in the run-up to PE 3.0! Well,
better late than never.
  • Loading branch information
nfagerlund committed Apr 18, 2014
1 parent ebb5a91 commit 9170bc5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/learning/modules2.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This is a doorway for passing information into the class:
{% endhighlight %}

* If you declare the class with a [resource-like class declaration](./modules1.html#resource-like-class-declarations), the parameters are available as **resource attributes.**
* If you declare the class with `include` (or leave out some parameters when using a resource-like declaration), Puppet will [automatically look up values][autolookup] for the parameters in your Hiera data.
* Inside the definition of the class, they appear as **local variables.**


Expand All @@ -72,6 +73,14 @@ To make your roles and profiles more flexible and avoid repeating yourself, you

[craigdunn_roles_profiles]: http://www.craigdunn.org/2012/05/239/

#### In Puppet Enterprise 3.x

In Puppet 3 and later, which are used in the Puppet Enterprise 3.x series, Puppet will automatically look up any unspecified class parameters in your [Hiera][] data. This means you can safely use `include` and the PE console with _any_ class (including those with mandatory no-default parameters), as long as you specify parameter values in your Hiera data.

Once you find yourself managing multiple nodes with Puppet, you should [read the section of the Hiera manual about automatic parameter lookup][autolookup]. Also, the [roles and profiles pattern][craigdunn_roles_profiles] recommended for Puppet Enterprise 2.x users remains relevant in PE 3.x.

You can also now specify class parameters directly in the PE console. However, this works best when using a small number of classes across a small number of nodes; for medium and large deployments, we recommend a combination of Hiera auto-lookup and the roles and profiles pattern.

#### Why `include` Can't Directly Take Class Parameters

The problem is that classes are singletons, parameters configure the way they behave, and `include` can declare the same class more than once.
Expand Down Expand Up @@ -211,3 +220,10 @@ Okay, we can pass parameters into classes now and change their behavior. Great!

Well, you'd [whip up a defined resource type](./definedtypes.html).

**Off-Road:**

You've seen how to configure classes in both your Hiera data and the PE console; why not grab a module and configure it for your own systems? [Download Puppet Enterprise for free][dl], follow [the quick start guide][quick] to get a small environment installed, install a module from the Puppet Forge ([maybe puppetlabs/ntp?](http://forge.puppetlabs.com/puppetlabs/ntp)), and assign it to a node in the console; don't forget to [add parameters][console_params].

[console_params]: insert_link_here
[dl]: http://info.puppetlabs.com/download-pe.html
[quick]: http://docs.puppetlabs.com/pe/latest/quick_start.html

0 comments on commit 9170bc5

Please sign in to comment.