Issue #8670 has been reported by Lluis Gili.
----------------------------------------
Feature #8670: create_resources or patch puppetmaster to accept hash directly?
https://projects.puppetlabs.com/issues/8670
Author: Lluis Gili
Status: Unreviewed
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.