Ask Your Question
0

Variable Precedence when applied with node

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

*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".

#vars.pp
$var1 = "value-vars"

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

#nodes.pp
node "/nodepattern/" inherits base {
require module1
}

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

#base.pp
$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
0

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

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

Stats

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

Seen: 289 times

Last updated: Aug 26 '14