Feature #1959
closedInstantiate Puppet define()s from ENC
Description
It would be very great if we could reuse parameterized classes. We are using puppet to install some tomcat instances on one machine. It should look like:
class tomcat
tomcat::tomcat_instance {instance_1
port => 10080
}
class tomcat
tomcat::tomcat_instance {instance_2
port => 10080
}
Updated by Ohad Levy about 12 years ago
- Status changed from New to Need more information
I'm not sure I follow, smart variables do exactly that, can you provide a bit more example of how you use it?
Updated by Jan Doleschal about 12 years ago
Ok, here is better example. We use this class to cleanup some systems. Cut from our site.pp I could not figure out how to realize it whith smart variables.
node server_1{
cleanup_2::cleanup {"/var/log/":
matches => ["zmd-messages.log.*", "zypper.log-*", "net-snmpd*", "warn*", "zmd-backend", "mail*", "log.*.old", "log.winbind-*.bz2", "*.bz2", "*.bz2-*", "*.log"],
recurse => true,
size => "100m",
age => "4w",
rmdirs => false,
}
cleanup_2::cleanup {"/var/puppet/clientbucket":
matches => "*",
recurse => true,
size => "50m",
age => "12w",
rmdirs => true,
}
include cleanup_2
}
Updated by Ohad Levy about 12 years ago
which version of foreman are you using? my guess is that you are using a version before parameterize class support was introduced?
Updated by Dominic Cleal about 12 years ago
Jan - is the cleanup_2::cleanup actually a define() rather than a parameterised class? Defines can be used multiple times, so that's what it looks like to me, while a class (even parameterised) can only be included once. If you could paste the start of the cleanup declaration that'd be useful to clarify.
Updated by Jan Doleschal about 12 years ago
Yes, it is a define. Of course you can include a class only one times. Sorry for the bad explanation. Here is the complete class.
class cleanup_2 {
define cleanup ($matches, $age, $size, $recurse, $rmdirs) {
tidy {"$name":
matches => $matches,
age => $age,
size => $size,
recurse => $recurse,
backup => false,
rmdirs => $rmdirs;
}
}
}
Updated by Dominic Cleal about 12 years ago
- Subject changed from Reuse parameterized classes to Instantiate Puppet define()s from ENC
- Status changed from Need more information to Assigned
Ok, thanks - that makes more sense.
I can see the use in this, but Puppet's ENC interface can only add classes to a node and not instantiate resources (or defines). This would depend on an extension to their ENC interface, or for Foreman to create classes of its own with the resources inside, then add that generated class to the node.
Updated by Dominic Cleal over 10 years ago
- Description updated (diff)
- Category set to Puppet integration
- Status changed from Assigned to New
Updated by Social Point about 10 years ago
Suggestion:
As said on http://projects.theforeman.org/projects/foreman/wiki/Instantiate_Puppet_resources
We can create a module for all wrappers
then for every define we want we just need to create a manifest, always with the same content.
For example, to be able to instantiate bind::server::conf of this module: https://forge.puppetlabs.com/thias/bind
We can create /etc/puppet/environments/production/modules/wrappers/manifests/bind/server/conf.pp with this content:
class wrappers::bind::server::conf($resources = {}) { create_resources('bind::server::conf', $resources) }
Then on foreman we can include that new class and for resource parameter we can provide this hash:
/etc/named.conf: listen_on_addr: - any listen_on_v6_addr: - any forwarders: - 8.8.8.8 - 8.8.4.4
Updated by Anonymous over 7 years ago
- Status changed from New to Feedback
I'm leaning towards closing this, as I can't image that Puppetlabs extend the ENC interface that way in the future