Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topscope variable is empty in (sub) modules #2866

Open
aloosnetmatch opened this issue Jul 15, 2024 · 0 comments
Open

Topscope variable is empty in (sub) modules #2866

aloosnetmatch opened this issue Jul 15, 2024 · 0 comments
Labels

Comments

@aloosnetmatch
Copy link

Describe the Bug

Topscope variable is empty is (sub) modules / classes, while the same variable IS known in the toplevel 00.pp

We have an 00.pp manifest files that sets a couple of top scope variables.
This 00.pp is executed for all agents.
We also have other manifests per server who offcourse call other classes.

00.pp

if '<value>' == $::facts.get('<value>') {
  $az_environment = 'prod'
  $test2 = "test2"
}

$test1 = "test1"
notify {"toplevel scope_test1    : ${::test1}" :}
notify {"toplevel scope_test2    : ${::test2}" :}

test.pp

class test {
  notify {"test class scope_test1    : ${::test1}" :}
  notify {"test class scope_test2    : ${::test2}" :}
}

When we apply (and the if statement = "True" ) , we get the results

Notice: toplevel scope_test1    : test1
Notice: toplevel scope_test2    : test2
Notice: test class scope_test1    : 
Notice: test class scope_test2    : test2

Expected Behavior

I expect the top scope variable test1 to always a have the defined value, since it's defined in the top scope.
Also remarkable is that when the variable test2 is within the "if" statement , the value works as expected.
Moving the variable outside of the "if" statement , makes it "empty" in the sub modules / classes.

Environment

We run puppetserver 7.17.0 and client versions 6.28.0 / 7.31.0.

Additional Context

I noticed this issue:

https://www.puppet.com/docs/puppet/7/known_issues_puppet#pup-11437

In Puppet 6.26 and 7.14, the lookup command fails to resolve toplevel facts in hiera configs if you're using the --environment option

We run a higher version already. (7.17.0)

@aloosnetmatch aloosnetmatch changed the title Topscope variable is empty is (sub) modules Topscope variable is empty in (sub) modules Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant