1 # Test whether a given class or definition is defined
2 require 'puppet/parser/functions'
4 Puppet::Parser::Functions.newfunction(:defined_with_params,
7 Takes a resource reference and an optional hash of attributes.
9 Returns true if a resource with the specified attributes has already been added
10 to the catalog, and false otherwise.
16 if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
17 user { 'dan': ensure => present, }
21 reference, params = vals
22 raise(ArgumentError, 'Must specify a reference') unless reference
23 if (! params) || params == ''
27 if resource = findresource(reference.to_s)
28 matches = params.collect do |key, value|
29 resource[key] == value
31 ret = params.empty? || !matches.include?(false)
33 Puppet.debug("Resource #{reference} was not determined to be defined")