puppetlabs-stdlib/lib/puppet/parser/functions
Dan Bode ba789deac5 Add function ensure_resource and defined_with_params
This commit adds 2 new functions with unit tests.

defined_with_params works similarily to puppet's defined
function, except it allows you to also specify a hash of
params. defined_with_params will return true if a resource
also exists that matches the specified type/title (just like
with defined) as well as all of the specified params.

ensure_resource is a function that basically combines defined_with_params
with create_resources to conditionally create resources only if the
specified resource (title, type, params) does not already exist.

These functions are created to serve as an alternative to using
defined as follows:

    if ! defined(Package['some_package']) {
      package { 'some_package': ensure => present,
    }

The issue with this usage is that there is no guarentee about
what parameters were set in the previous definition of the package
that made its way into the catalog.

ensure_resource could be used instead, as:

    ensure_resource('package', 'some_package', { 'ensure' => 'present' })

This will creat the package resources only if another resource does
not exist with the specified parameters.
2012-08-13 17:09:10 -07:00
..
abs.rb Added doc strings for first five functions 2011-07-30 04:22:30 +10:00
bool2num.rb Added doc strings for first five functions 2011-07-30 04:22:30 +10:00
capitalize.rb Added doc strings for first five functions 2011-07-30 04:22:30 +10:00
chomp.rb Added doc strings for first five functions 2011-07-30 04:22:30 +10:00
chop.rb Added doc strings for first five functions 2011-07-30 04:22:30 +10:00
defined_with_params.rb Add function ensure_resource and defined_with_params 2012-08-13 17:09:10 -07:00
delete.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
delete_at.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
downcase.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
empty.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
ensure_resource.rb Add function ensure_resource and defined_with_params 2012-08-13 17:09:10 -07:00
flatten.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
fqdn_rotate.rb (#13205) Rotate array/string randomley based on fqdn, fqdn_rotate() 2012-03-18 12:19:48 +01:00
get_module_path.rb (Maint) Fix up the get_module_path parser function 2012-07-23 09:21:22 -07:00
getvar.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
grep.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
has_key.rb Docs: Correct indentation of markdown code examples 2011-08-18 12:39:04 -07:00
hash.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_array.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_domain_name.rb Check according to rfc1035 2012-01-11 19:17:03 -08:00
is_float.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_hash.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_integer.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_ip_address.rb Prep for stdlib merge 2011-08-05 08:25:03 +01:00
is_mac_address.rb Prep for stdlib merge 2011-08-05 08:25:03 +01:00
is_numeric.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
is_string.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
join.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
keys.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
loadyaml.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
lstrip.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
member.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
merge.rb Docs: Improve example in merge function 2011-08-18 12:39:04 -07:00
num2bool.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
parsejson.rb (#10285) Refactor json to use pson instead. 2011-10-25 15:54:47 -07:00
parseyaml.rb Prep for stdlib merge 2011-08-05 08:25:03 +01:00
prefix.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
range.rb (#13494) Specify the behavior of zero padded strings 2012-03-29 15:17:30 -07:00
reverse.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
rstrip.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
shuffle.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
size.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
sort.rb Fix some ruby 1.9.2 issues. 2011-07-30 00:44:02 +01:00
squeeze.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
str2bool.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
str2saltedsha512.rb New str2saltedsha512 function for OS X Passwords 2012-01-09 11:30:47 -08:00
strftime.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
strip.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
swapcase.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
time.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
type.rb (#3) Provide documentation for remaining functions. 2011-07-29 23:09:30 +01:00
unique.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
upcase.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
validate_absolute_path.rb (#12357) Fix broken compatibility with Puppet 2.6 2012-03-12 15:59:50 -07:00
validate_array.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
validate_bool.rb Docs: Remove author emails from stdlib functions 2011-08-18 12:39:05 -07:00
validate_hash.rb Docs: Remove author emails from stdlib functions 2011-08-18 12:39:05 -07:00
validate_re.rb (maint) Comment Ken's fix to String#any? 2012-03-09 14:08:54 -08:00
validate_slength.rb (#12776) Added validate_slength function and rspec test 2012-02-22 18:12:34 +00:00
validate_string.rb Docs: Copyedit function doc strings 2011-08-18 12:39:04 -07:00
values.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00
values_at.rb Fix some ruby 1.9.2 issues. 2011-07-30 00:44:02 +01:00
zip.rb (#3) Apply missing documentation to more functions. 2011-07-29 22:18:56 +01:00