Speaking of things to avoid, there is a language feature that we will only address in order to advise great caution. Puppet comes with a function called defined, which allows you to query the compiler about resources that have been declared in the manifest:
if defined(File['/etc/motd']) { notify { 'This machine has a MotD': } }
The problem with the concept is that it cannot ever be reliable. Even if the resource appears in the manifest, the compiler might encounter it later than the if condition. This is potentially very problematic, because some modules will try to make themselves portable through this construct:
if ! defined(Package['apache2']) { package { 'apache2': ensure => 'installed' } }
The module author supposes that this resource definition will be skipped if
the manifest...