On Dec 12, 8:42 am, Darin Perusich <da...@darins.net> wrote: > >> In the first place, your definition is a bit screwey in that it cannot > >> be instantiated more than once (you would get a duplicate resource > >> error on File['sshd_config']). A definition creates a resource *type* > >> but you're using it as if it created a single resource. > > >> And that leads directly to the crux of your problem: at the point > >> where your service resource is parsed, no instance of the definition > >> can yet have been created, and therefore File['sshd_config'] cannot > >> yet have been declared. The service cannot declare a dependency on an > >> undeclared resource. > > >> Since you would prefer to put the definition in its own file anyway, I > >> recommend you do so. Then, add "include 'ssh'" at the beginning of > >> its body and re-enable the 'notify' parameter in the file resource. > >> Remove the 'subscribe' from the service resource, but add "require => > >> Package['ssh']". Then you should be good to go. > > > I'll give these changes a try and let you know how things turn out. > > I've updated the module using your recommendations and it is working > nicely, however I do get the duplicate resource on File['sshd_config'] > if/when it's set multiple times. What would be the recommended way to of > handling this? Other than not duplicating the resource.
Declaring a duplicate resource will always cause Puppet to throw an error during catalog compilation. This is an intentional behavior, and there is no way to avoid it other than not duplicating the resource. A better question, then, is how to avoid duplicating the resource. One way, of course, is to be careful about when and where you instantiate your definition. I gather that's what you are trying to avoid. I now refer you to my earlier remarks about the right way to approach this problem: that is, the right way is to use a class rather than a definition. By itself, however, that's not enough to solve a duplicate resource problem. You must be sure to change to an *unparameterized* class, and you should use the 'include' function to assign it to nodes in all the places where you now instantiate the definition. This means you will need an alternative mechanism for feeding data to the class (since parameters are not viable for this scenario). A good alternative is external data accessed via extlookup() or hiera, but you could also use class variables (of some other class) or global variables. Or perhaps you can make the class smart enough to figure out the appropriate values itself. John -- 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.