Ask Your Question

Variable Precedence when applied with node

asked 2014-08-26 03:53:03 -0600

*cloning from stackoverflow

In the setup I'm working the variable $var1 is declared in several places. However I'm not sure which line is last applied. The structure is as follows.

The puppet module, module1, contains a vars.pp manifest which is inherited by its init.pp manifest. In the vars.pp manifest var1 is declared as "value-vars".

$var1 = "value-vars"

This module is applied to any node that matches a certain regex which is defined in the nodes.pp.

node "/nodepattern/" inherits base {
require module1

nodes.pp inherits from base.pp which declares var1 as "value-base".

$var1 = "value-base"

Now when the module is applied to a certain node, what value would var1 contain?

Is it "value-vars" because node block is applied before the class?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-26 13:36:26 -0600

WhatsARanjit gravatar image

This is a scope issue. The variables from an "overhead" view are $base::var1 and $vars::var1. You should be very explicit when you're working with variables across classes. Also, you can never set and then reset the same variable (in a scope). Check out this doc.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-08-26 03:53:03 -0600

Seen: 324 times

Last updated: Aug 26 '14