On Mon, Aug 13, 2012 at 8:31 AM, Zachary Stern <z...@enternewmedia.com> wrote:

> Ok, that's helpful, however:
>
>
> On Sun, Aug 12, 2012 at 8:43 AM, Eric Shamow <e...@puppetlabs.com> wrote:
>
>> An example: suppose is this module you say $puppetmaster =
>> "myserver.local" and in another module, you want to only run on a puppet
>> master and so say $puppetmaster = true. When Puppet assembles the model of
>> your system, which of the two is to be applied where? Dynamic scoping tried
>> to guess at this. The idea here is to say, eliminate ambiguity - tell us
>> exactly which one you want.
>
>
> Sure, I get that, but I'm trying to do this within the module, not
> globally.
> Also imagine the following scenario.
>
> I've configured the params.pp file to contain various things like
> $puppet::params:puppetserver - but what if I want to override that in a
> particular manfiest, but use the same template erb file for configuration.
> I can't, because I've used the scope.lookupvar tool in the manifest, rather
> than just doing <%= puppetserver %> and having that variable take on a
> value based on context - not in terms of "dynamic scoping" but in terms of
> being able to, as discussed, include params.pp, or define it inside the
> manifest that is using the template.
>
> Is there any way to achieve this on-the-fly variable-changing, short of
> using hiera or something like that? I'm just not there yet.
>

This is typically modeled via:

class puppet (
  $server = $puppet::params::server
) include puppet::params {
...
}

This allows any variables be overwritten in declaration, while allowing the
template to simply use $puppet::server. Most Puppet Labs forge modules use
this pattern, so take a look at them if you need a more complex example.

Nan

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to