Ask Your Question

how do I check if a fact is defined?

asked 2016-05-04 11:11:47 -0500

jordiprats gravatar image

Some of my modules are checking if a fact is defined, for example:


In puppet 4.4.2 I get this warning:

Warning: Undefined variable 'eyp_docker_iscontainer'; 
   (file & line not available)

how do I check if a fact is defined without getting this warning?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-05-04 11:41:50 -0500

Try this

if defined('$::eyp_docker_iscontainer') {

Or if you have stdlib available:

if has_key($facts, 'eyp_docker_iscontainer') {

In Puppet 4, as a point of style, use of the $facts hash is preferred, see here.

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


Asked: 2016-05-04 11:11:47 -0500

Seen: 568 times

Last updated: May 04 '16