Hi all, even though I''ve read some postings about run stages, I''m still having trouble using them correctly. First of all: Is it possible to add a stage directly when defining a class? That question has already been asked here (in section 2): http://groups.google.com/group/puppet-users/browse_thread/thread/a4c9ee83039ddff3/3cfe92dd495f069a If that wasn''t possible, I''ve gathered from other threads, that I would have to add stages to my node definitions, like so: node ab_basenode { include "baseconfig" include "ab_baseconfig" class { "afs": stage => first } } However, this does not work, as it produces: Duplicate definition: Class[afs] is already defined; cannot redefine. This makes sense, as class "afs" is indeed defined in module "baseconfig". Does that mean, that I can only use the above stage resource declaration syntax when defining the class "afs" directly inside "ab_basenode" (instead of including it)? A few more words explaining the manifest/module structure: I have the modules "baseconfig" (default configuration for all nodes of our institute) and "ab_baseconfig" (default configuration for department "AB"). Both modules have many classes, one of which configures the AFS file system client (class "afs"). The two modules above are included into node "ab_basenode", which is a default node for department "AB". The actual physical nodes of department "AB" are then defined by inheritance "node taranaki.domainname.de inherits ab_basenode" and contain node-specific configuration (e.g. webserver config). I hope, someone understands, what I am trying to do and might shed some light onto the stage problem. As I''m new to puppet, I would also appreciate criticism about the manifest/module structure - maybe I''m doing things too complicated? Best regards, Jan -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Jan-25 11:13 UTC
Re: [Puppet Users] Another question concerning run stages
On 01/25/2011 11:54 AM, Jan wrote:> Hi all, > > even though I''ve read some postings about run stages, I''m still having > trouble using them correctly. > > First of all: Is it possible to add a stage directly when defining a > class? That question has already been asked here (in section 2): > http://groups.google.com/group/puppet-users/browse_thread/thread/a4c9ee83039ddff3/3cfe92dd495f069a > > If that wasn''t possible, I''ve gathered from other threads, that I > would have to add stages to my node definitions, like so: > node ab_basenode { > include "baseconfig" > include "ab_baseconfig" > class { "afs": stage => first } > }Hi, I won''t pretend I understand your whole problem, but you obviosly try and change a parameter (stage in this case) of a resource (here: class afs) that has already been declared. There are two ways that spring to mind. 1. Class inheritance: Inherit the class that declares "class afs" in the first place. In the subclass, just do Class["afs"] { stage => first } Then include the subclass in your node. Finished. 2. Exported Resources Override (http://projects.puppetlabs.com/projects/1/wiki/Exported_Resources) Instead of your above re-declaration of class afs, try Class<| name == "afs" |> { stage => first } This should do roughly the same as the class inheritance solution, minus the class inheritance. I try to avoid it, as it is convoluted and I don''t really trust it ;-) HTH, Felix -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jan 25, 12:13 pm, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> On 01/25/2011 11:54 AM, Jan wrote: > > > > > Hi all, > > > even though I''ve read some postings about run stages, I''m still having > > trouble using them correctly. > > > First of all: Is it possible to add a stage directly when defining a > > class? That question has already been asked here (in section 2): > >http://groups.google.com/group/puppet-users/browse_thread/thread/a4c9... > > > If that wasn''t possible, I''ve gathered from other threads, that I > > would have to add stages to my node definitions, like so: > > node ab_basenode { > > include "baseconfig" > > include "ab_baseconfig" > > class { "afs": stage => first } > > } > > Hi, > > I won''t pretend I understand your whole problem, but you obviosly try > and change a parameter (stage in this case) of a resource (here: class > afs) that has already been declared. > > There are two ways that spring to mind. > > 1. Class inheritance: > Inherit the class that declares "class afs" in the first place. In the > subclass, just do > Class["afs"] { stage => first } > Then include the subclass in your node. Finished.I am now trying without any module to make debugging easier. I''ve got the following: class afs { service { "openafs-client": enable => true, ensure => running, } } class afs_staging inherits afs { Class["afs"] { stage => "first" } } In the node, I directly use "include afs_staging", nothing else. However, it does not work yet. Puppet seems to ignore afs_staging and applies afs in main stage: notice: Starting Puppet client version 2.6.4 [...] info: Caching catalog for taranaki.informatik.uni-tuebingen.de [...] debug: Loaded state in 0.01 seconds debug: /Stage[last]/require: requires Stage[main] debug: /Stage[first]/before: requires Stage[main] info: Applying configuration version ''1295962148'' [...] notice: /Stage[main]/Afs/Service[openafs-client]/ensure: ensure changed ''stopped'' to ''running'' [...] notice: Finished catalog run in 0.37 seconds Any ideas on that?> 2. Exported Resources Override > (http://projects.puppetlabs.com/projects/1/wiki/Exported_Resources) > Instead of your above re-declaration of class afs, try > Class<| name == "afs" |> { stage => first } > This should do roughly the same as the class inheritance solution, minus > the class inheritance. > I try to avoid it, as it is convoluted and I don''t really trust it ;-)Are you sure, this works for classes as well? When using it with a class, I get the following error: Could not retrieve catalog from remote server: Error 400 on SERVER: undefined method `name'' for nil:NilClass. (That "name" does not refer to the filter condition, it seems to be a more generic Ruby error.) I can get Exported Resources Override to work with resource type File, however. Regards, Jan -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Jan-25 14:21 UTC
Re: [Puppet Users] Re: Another question concerning run stages
> I am now trying without any module to make debugging easier. I''ve got > the following: > class afs { > service { "openafs-client": > enable => true, > ensure => running, > } > } > class afs_staging inherits afs { > Class["afs"] { stage => "first" } > }Not quite correct. You need this (some assumptions made): class baseconfig { class { "afs": } ... } class baseconfig_afs_staging inherits baseconfig { Class["afs"] { stage => "first" } } Then include baseconfig_afs_staging. HTH, Felix -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 25 Jan., 15:21, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> > I am now trying without any module to make debugging easier. I''ve got > > the following: > > class afs { > > service { "openafs-client": > > enable => true, > > ensure => running, > > } > > } > > class afs_staging inherits afs { > > Class["afs"] {stage=> "first" } > > } > > Not quite correct. > > You need this (some assumptions made): > > class baseconfig { > class { "afs": } > ... > > } > > class baseconfig_afs_staging inherits baseconfig { > Class["afs"] {stage=> "first" } > > } > > Then include baseconfig_afs_staging. > > HTH, > FelixThanks, it''s working now. I hadn''t understood, that I needed that enclosing class (the ''baseconfig'' in your example). In that case, I don''t even have to use inheritance. I''m now going with the following, which works fine for me: class baseconfig_ubuntu { class { "afs": stage => "first"; [...] } class afs { service { [...] } } } -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.