Issue #8670 has been updated by Andrew Parker.

Status changed from Needs Decision to Duplicate
Assignee deleted (Nigel Kersten)

This is actually a duplicate of the request in #1858. That issue had been 
closed because it appears there was an assumption made that some code change 
would enable this functionality, but that never happened. I'm closing this as a 
duplicate and re-opening the other issue and setting it to "Needs Decision".

----------------------------------------
Feature #8670: create_resources or patch puppetmaster to accept hash directly?
https://projects.puppetlabs.com/issues/8670#change-94665

* Author: LluĂ­s Gili
* Status: Duplicate
* Priority: Normal
* Assignee: 
* Category: parser
* Target version: 
* Affected Puppet version: 
* Keywords: 
* Branch: 
----------------------------------------
We did a patch for puppetmaster that allowed to generate resources from a Hash 
(see #1858). Now we realized about **create_resources** function that does the 
same, and started to change our manifests to use it. After comparing both 
syntax, I think with our patch is more easy to use:

<ins>simple example</ins>

* external nodes yaml:
<pre>
classes:
  webserver::instances:
    instances:
      instance1:
        foo: bar
      instance2:
        foo: blah
</pre>

* manifest with function
<pre>
class webserver::instances ($instances = {}) {
  create_resources('webserver::instance', $instances)
}
</pre>

* manifest with patch
<pre>
class webserver::instances ($instances = {}) {
  webserver::instance { $instances: }
}
</pre>

<ins>example when you want to add parameters to the resources</ins>

* external nodes yaml:
<pre>
classes:
  nagios::server:
    serviceescalations: 
      escalation1: 
        last_notification: 0
        contact_groups: contactgroup1
        notification_interval: 720
        service_description: "*"
        first_notification: 2
        hostgroup_name: hostgroup1
</pre>


* manifest with function:
<pre>
class nagios::server($serviceescalations={}) {

  create_resources(nagios::server::serviceescalation, $serviceescalations)
  define 
serviceescalation($last_notification,$contact_groups,$notification_interval,$service_description,$first_notification,$hostgroup_name)
 {
    nagios_serviceescalation { $name:
      last_notification => $last_notification,
      contact_groups => $contact_groups,
      notification_interval => $notification_interval,
      service_description => $service_description,
      first_notification => $first_notification,
      hostgroup_name => $hostgroup_name,
      notify => Service["nagios"],
      require => File["/etc/nagios/nagios_serviceescalation.cfg"],
    }   
  }
}
</pre>

* manifest with patch:
<pre>
class nagios::server($serviceescalations={}) {

  nagios_serviceescalation { $serviceescalations:
    notify => Service["nagios"],
    require => File["/etc/nagios/nagios_serviceescalation.cfg"],
  }

}
</pre>


The patch is quite simple: 
https://github.com/ingent/puppet/commit/b631f105d5e5e221d1dc35238bc4f5938a28a3cf
We are fine using create_resources function, but think it's simpler if puppet 
accepts Hashes directly


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to