Ask Your Question

PDK. Error on top-scope variable inside iteration

asked 2018-06-15 10:13:59 -0500

daniel.serrao gravatar image


I got a very strange error where a variable is defined in the iteration and when running the "pdk validate" causes the error:

warning: puppet-lint: manifests/base/windows/features.pp:24:24: top-scope variable being used without an explicit namespace
warning: puppet-lint: manifests/base/windows/features.pp:26:37: top-scope variable being used without an explicit namespace

The code is the following:

$features_present = lookup('profile::module::features_present', Array[String], 'deep', [])

$features_present.each |$f| {
  reboot {"Reboot ${f}": #Warning here
    when      => pending,
    subscribe => Windowsfeature[$f],  #Warning here

I know that is a known bug of puppet-lint and that it should be fixed, but it is strange that I have other similar code that don't cause the same error.

The pdk version is 1.4.1 and the puppet version is 5.5.1.

Any idea on how to solve this?

Kind regards

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-18 09:58:24 -0500

daniel.serrao gravatar image

Taking into consideration that I didn't receive any answer and that this seems to be a bug of the puppet-lint, the workaround was to use # lint:ignore:variable_scope at the beginning of the class and # lint:endignore at the end of the class.

What this does is to ignore the top-scope variables errors in the class.

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


Asked: 2018-06-15 10:13:59 -0500

Seen: 100 times

Last updated: Jun 18