Skip to content

Instantly share code, notes, and snippets.

@bodepd
Created September 2, 2014 10:15
Show Gist options
  • Save bodepd/96daf31c92f340bebb20 to your computer and use it in GitHub Desktop.
Save bodepd/96daf31c92f340bebb20 to your computer and use it in GitHub Desktop.
class foo {
$bar = 'one'
}
node /foo/ {
$bar = 'two'
include foo
notice("${::foo::bar}")
}
@thwarted
Copy link

thwarted commented Sep 2, 2014

@ahpook It seems to occur when the hostname is the same the as the class, yes. And then in that case, I think ${::foo::bar} being "two" within the scope of the node makes sense, although it's lame that you then can't access members scoped to the class.

@bodepd
Copy link
Author

bodepd commented Sep 3, 2014

@ahpook This error only occurs when the node name happens to match the class name. In that case, it appears that:

notice("${::foo::bar}")

will resolve ::foo::bar as the $bar variable from the namespace of the node scope and not as the bar variable from the namespace of the foo class.

@bodepd
Copy link
Author

bodepd commented Sep 3, 2014

@ahpook

# puppet apply --certname foo123 -e '
> class foo {
>   $bar = 'one'
> }
> 
> node /foo/ {
>   $bar = 'two'
>   include foo
>   notice("${::foo::bar}")
> }
> '
Notice: Scope(Node[foo]): two
Notice: Compiled catalog for foo123 in environment production in 0.02 seconds
Notice: Finished catalog run in 0.03 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment