I have pre, main, and post stages configured in my manifests. When I assign variables in the node declaration they are present in the main stage, but not my pre-stage. How do I assign variables at the node level that can be referenced in my pre stage? -Chip Schweiss -- 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 05/23/2011 12:34 PM, Chip wrote:> I have pre, main, and post stages configured in my manifests. > > When I assign variables in the node declaration they are present in > the main stage, but not my pre-stage. > > How do I assign variables at the node level that can be referenced in > my pre stage? > > -Chip Schweiss >I''m also curious how variables interact with stages in general. I was really anticipating them to solve some long-standing problems at this one gig and it turned out that it worked absolutely nothing I thought it would. -- Joe McDonagh IT Infrastructure Consultant AIM: YoosingYoonickz IRC: joe-mac on freenode "When the going gets weird, the weird turn pro." -- 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 Mon, May 23, 2011 at 9:34 AM, Chip <chip.schweiss@gmail.com> wrote:> I have pre, main, and post stages configured in my manifests. > > When I assign variables in the node declaration they are present in > the main stage, but not my pre-stage. > > How do I assign variables at the node level that can be referenced in > my pre stage?Not sure how that would be affect by stages: class a { notify { $var:} } node default { $var = "hi!" stage { "pre": before => Stage[''main''], } class { a: stage => ''pre'', } } notice: hi! notice: /Stage[pre]/A/Notify[hi!]/message: defined ''message'' as ''hi!'' The only thing I suspect is the variable is declared after the class have been declared. A concrete example or pastie of your code would be beneficial to diagnose this further. Thanks, Nan -- 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.
The pre classes are definately getting defined before the variable is being
declared in my node definition:
node ''deploy.nrg.mir'' {
    $deployment = true
    $deploy_environment = "development"
    $deploy_hostname = "testhost"
    $deploy_fqdn = "testhost.nrg.mir"
    $deploy_netadapters = "2"
    notify { "node:deploy":
        message => "deploy_fqdn: $deploy_fqdn"
    }
    include baseclass
    include deploy
}
In my site.pp:
....lines deleted...
import "templates.pp"
import "nodes/*"
import "classes/*"
import "os/*"
import "common"
stage { [pre, post]: }
Stage[pre] -> Stage[main] -> Stage[post]
class {
    "network": stage => pre;
    "pre_baseclass": stage => pre;
    "postclass": stage=> post;
}
In my network class I want to use deploy_* variables defined in the node.
I not sure how to get puppet to always load the node definition before all
other classes.  Almost seems like a bug.
-Chip
-- 
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 Tue, May 24, 2011 at 9:46 AM, Chip Schweiss <chip.schweiss@gmail.com> wrote:> The pre classes are definately getting defined before the variable is being > declared in my node definition: > > node ''deploy.nrg.mir'' { > $deployment = true > $deploy_environment = "development" > $deploy_hostname = "testhost" > $deploy_fqdn = "testhost.nrg.mir" > $deploy_netadapters = "2" > > notify { "node:deploy": > message => "deploy_fqdn: $deploy_fqdn" > } > > include baseclass > include deploy > } > > In my site.pp: > > ....lines deleted... > > import "templates.pp" > import "nodes/*" > import "classes/*" > import "os/*" > import "common" > > stage { [pre, post]: } > Stage[pre] -> Stage[main] -> Stage[post] > > class { > "network": stage => pre; > "pre_baseclass": stage => pre; > "postclass": stage=> post; > } > > In my network class I want to use deploy_* variables defined in the node. > I not sure how to get puppet to always load the node definition before all > other classes. Almost seems like a bug.Well it''s not a bug, your variables are nested in node scope and it''s not available because the class is declared in top scope. You effectively are doing: node sample { $var = ''value'' } class { ''network'': } Declare the class in the node scope and you should have access to $var. node sample { $var = ''value'' class { ''network'': } } Another options is to access the variable with it''s explicit scope $sample::var. Thanks, Nan -- 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.