Ask Your Question
0

How do you do strict variable checking?

asked 2014-10-29 11:06:33 -0500

spuder gravatar image

As of puppet 3.6, you can enable strict variable checking.

How do you enable it? And what exactly does it do?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-10-29 11:14:18 -0500

spuder gravatar image

I recently wrote a blog article on how to enable strict variable checking.

http://spuder.github.io/jekyll/update...

Basically to use it, add the following environment variable, then run your tests

export STRICT_VARIABLES=yes
rake spec

Strict variable checking will cause puppet to throw an error if a variable (or facter fact) is not defined. This prevents hard to troubleshoot errors.

For example, given the puppet code:

notice("download from http://example.com/$::foo/bar")

If $::foo is not defined, then puppet could return a result like this:

download from http://example.com//bar

With strict variable checking enabled, puppet would throw a warning.

You can easily enable it in your travis tests like so:

env:
  - PUPPET_VERSION=3.1.0 FACTER_VERSION=1.7.6
  - PUPPET_VERSION=3.4.0 FACTER_VERSION=2.0.2
  - PUPPET_VERSION=3.6.0 FACTER_VERSION=2.1.0
  - PUPPET_VERSION=3.6.0 FACTER_VERSION=2.1.0 STRICT_VARIABLES=yes
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-10-29 11:06:33 -0500

Seen: 436 times

Last updated: Oct 29 '14