Ask Your Question

how to check if fact exists in manifest file?

asked 2014-02-04 09:17:37 -0500

sysadmin gravatar image


Can someone tell me how to check if fact exists and not null on system within the manifest file?


edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted

answered 2014-02-04 09:28:29 -0500

doc75 gravatar image

I would do it like that:

if $factname != undef {
} else {

Hope this helps.

edit flag offensive delete link more


if $ipaddress_eth0 != undef { template... } I'm getting this error: "error: could not parse for environment production: syntax error at ipaddress_eth0'; expected } at ...."

sysadmin gravatar imagesysadmin ( 2014-02-05 00:11:59 -0500 )edit

Could you please post your code somewhere. I am not sure but this it probably not related to this way of doing.

doc75 gravatar imagedoc75 ( 2014-02-05 04:07:43 -0500 )edit

There's also the the “defined” function .

Kai Burghardt gravatar imageKai Burghardt ( 2016-11-07 08:06:39 -0500 )edit

answered 2016-11-03 08:53:20 -0500

AmberW gravatar image

This question is a bit old but I found it before I found the answer. Hope this helps!

if $facts['is_virtual'] {
  warning('Tried to include class ntp on virtual machine; this node may be misclassified.')
elsif $facts['os']['family'] == 'Darwin' {
  warning('This NTP module does not yet work on our Mac laptops.')
else {
  include ntp