diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-08-24 15:42:03 -0700 |
---|---|---|
committer | Nick Lewis <nick@puppetlabs.com> | 2011-08-24 15:42:03 -0700 |
commit | da4a2def42639817c4522fc0162bd691956998da (patch) | |
tree | 3cb423a7d2a7a803a922b710c661d675d11bf131 /lib/puppet/parser/functions/create_resources.rb | |
parent | 0d51dc9be0bc1c785d749b8b352a1e43b1b6e9c6 (diff) | |
parent | 630ec36089e2224fba99b76d76eaf904af13e4d6 (diff) | |
download | puppet-da4a2def42639817c4522fc0162bd691956998da.tar.gz puppet-da4a2def42639817c4522fc0162bd691956998da.tar.xz puppet-da4a2def42639817c4522fc0162bd691956998da.zip |
Merge branch '2.7.x'
Conflicts:
lib/puppet/feature/base.rb
lib/puppet/file_serving/configuration.rb
spec/unit/indirector/ssl_file_spec.rb
spec/unit/parser/functions/extlookup_spec.rb
spec/unit/resource/catalog_spec.rb
test/language/ast/variable.rb
Diffstat (limited to 'lib/puppet/parser/functions/create_resources.rb')
-rw-r--r-- | lib/puppet/parser/functions/create_resources.rb | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/puppet/parser/functions/create_resources.rb b/lib/puppet/parser/functions/create_resources.rb index 3b8bb3543..646761957 100644 --- a/lib/puppet/parser/functions/create_resources.rb +++ b/lib/puppet/parser/functions/create_resources.rb @@ -1,12 +1,24 @@ -Puppet::Parser::Functions::newfunction(:create_resources, :doc => ' -Converts a hash into a set of resources and adds them to the catalog. -Takes two parameters: - create_resource($type, $resources) - Creates resources of type $type from the $resources hash. Assumes that - hash is in the following form: - {title=>{parameters}} - This is currently tested for defined resources, classes, as well as native types -') do |args| +Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC') do |args| + Converts a hash into a set of resources and adds them to the catalog. + + This function takes two arguments: a resource type, and a hash describing + a set of resources. The hash should be in the form `{title => {parameters} }`: + + # A hash of user resources: + $myusers = { + 'nick' => { uid => '1330', + group => allstaff, + groups => ['developers', 'operations', 'release'], } + 'dan' => { uid => '1308', + group => allstaff, + groups => ['developers', 'prosvc', 'release'], } + } + + create_resource(user, $myusers) + + This function can be used to create defined resources and classes, as well + as native resources. + ENDHEREDOC raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2 #raise ArgumentError, 'requires resource type and param hash' if args.size < 2 # figure out what kind of resource we are @@ -19,7 +31,7 @@ Takes two parameters: type_of_resource = :type elsif resource = find_definition(type_name.downcase) type_of_resource = :define - else + else raise ArgumentError, "could not create resource of unknown type #{type_name}" end end |