# how do I check if a fact is defined?

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

if($::eyp_docker_iscontainer!=undef) { ... }  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? thanks edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted 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.

more