Ask Your Question
0

setting module variables to the same name

asked 2016-05-06 08:37:43 -0500

updated 2016-05-10 03:37:24 -0500

ramindk gravatar image

I ran across the following snippet in a forge module and I'm trying to figure out the use case for such a design. Why would you set a variable to the same variable?

class windows_ad::install (
    $ensure = $ensure,
    $installmanagementtools = $installmanagementtools,
    $installsubfeatures = $installsubfeatures,
    $restart = $restart,
    $installflag = $installflag,
) {
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-05-06 13:50:45 -0500

mike.r gravatar image

is there anything thats doing a var unset before this class? Even with that, you still need to pass vars from somewhere like a Params class or Hiera. Strange design. Does the module work?

edit flag offensive delete link more
1

answered 2016-05-09 13:43:55 -0500

Henrik Lindberg gravatar image

If that is exactly what is in the module then it looks wrong. There is no inherits which would explain where the values come from. Instead the code in a roundabout way says that each value is the value of itself. It may work at runtime, but it is not achieving the effect of setting any default values - unless, (horror) the values are set as global variables someplace else.

Looks like a mistake that just means that values must either be given or come from automatic data binding (via hiera). The code above with a later puppet (4.x) will result in errors as something like $restart = $restart is self referential.

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

Stats

Asked: 2016-05-06 08:37:43 -0500

Seen: 655 times

Last updated: May 10 '16