On 10/15/2012 11:44 PM, Stefan Schulte wrote: > The instances method is a class method and has to return an array of > providers. So this often looks like this > > def self.instances > systems = [] > my_fancy_command.each_line do |line| > somehow_split_line_into_different_fields_like_name_and_interfaces > systems << new( > :name => name, > :interfaces => interfaces, > :ensure => :present > ) > end > systems > end
Huh, so I have to build whole resources in self.instances, with all the possible properties? > This command can either return with a non zero exit code (no packages > found) in case we have zero keys or it will print one line per key. > For each line a provider instance is added to the array that is finally > returned. Got it from the upper code. > I hope that helps. An example of a query method can be found in the > package provider in puppet core. The package provider is a bit special > here because it does not trust its prefetched values. This is because > one resource can change the state of another resource: > > package { "mod_ssl": ensure => installed } > package { "httpd": ensure => installed } > > The ensure property of "httpd" can change in the middle of a puppetrun (if > mod_ssl is installed first httpd will be installed as a dependency) > so the prefetched value of :absent can be obsolete when puppet actually > handles the resource Package["httpd"]. For you cobblersystem type I do > not think that one resource may influence another resource right? Yeah, you are right, one cobblersystem instance cannot influence creation or modification of other instance. But now that you mention, I do have one more question in this regard. Is it possible for some property to create auto-require with some other resource? Except from cobblersystem I do have 3 another custom types (cobblerprofile, cobblerdistro and cobblerrepo). So, for example: cobblerprofile { 'foo': ensure => present, } cobblersystem { 'bar': ensure => present, profile => 'foo', require => Cobblerprofile['foo'], } Is there a way to skip the last require, and force it through profile property in the type/provider code? Thank you so much for the great explanation. I will save it and try to code it first on my simpler types like cobblerprofile and if I succeed will jump into fire and rewrite cobblersystem. ty. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.