I''m looking for a method to access a variable set in my main state from a class in my post stage? Is this possible? Any know way of passing the information? -- 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.
That sounds suspiciously like procedural thinking about a declarative language. You should understand that in puppet everything is ''set'' before anything is ''done''. Stages just help to order the ''get it done'' part. So the answer to your question about "a method to access a variable" is: just access it! $foo = $otherclass::baz -- vagn On 07/07/2011 09:19 AM, Chip Schweiss wrote:> I''m looking for a method to access a variable set in my main state > from a class in my post stage?-- 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.
That leads to the next question. How to access a variable set in the node declaration from a class that executes in the post stage? On Thu, Jul 7, 2011 at 11:51 PM, vagn scott <vagnscott@gmail.com> wrote:> > That sounds suspiciously like procedural thinking about a declarative > language. > > You should understand that in puppet everything is ''set'' before anything is > ''done''. > Stages just help to order the ''get it done'' part. > > So the answer to your question about "a method to access a variable" is: > just access it! > > $foo = $otherclass::baz > > -- > vagn > > > > > On 07/07/2011 09:19 AM, Chip Schweiss wrote: > >> I''m looking for a method to access a variable set in my main state from a >> class in my post stage? >> > > -- > 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 <puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> > . > >-- 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 07/08/2011 04:10 PM, Chip Schweiss wrote:> > How to access a variable set in the node declaration from a class that > executes in the post stage?The answer is the same whether you use stages or not. Put your variables in a class. Below was tested on puppet 2.7.1. Per node stuff (eg mood) has to be passed in the argument list. Site wide stuff can be defined in the body of class config. node vm01 { class { ''config'': mood => "grumpy", } class { ''sleepy'': stage => post, } notice("done with vm01") } class config($mood) { $h = { a => "aaa", b => "bbb" } $nodefoo = "this is nodefoo" } class sleepy { $foo = $config::mood $baz = $config::nodefoo notice("dopey feels ${foo}") notice("nodefoo is: ${baz}") notice("b is ${$config::h[ ''b'' ]}") } Jul 8 17:58:39 gena puppet-master[23503]: (Scope(Class[Sleepy])) dopey feels grumpy Jul 8 17:58:39 gena puppet-master[23503]: (Scope(Class[Sleepy])) nodefoo is: this is nodefoo Jul 8 17:58:39 gena puppet-master[23503]: (Scope(Class[Sleepy])) b is bbb Jul 8 17:58:39 gena puppet-master[23503]: (Scope(Node[vm01.lan3])) done with vm01 Jul 8 17:58:39 gena puppet-master[23503]: Compiled catalog for vm01.lan3 in environment production in 0.27 seconds -- 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.