List I want to have a per server snmp password setup. When I set it up as below and run the client it is unable to process the module because it cannot find the $snmp_password. Is there a way to export a $variable from a node so it can be read when the node processes one of its inherited modules? Is there something I can put in the inherited node like import $variable before the included modules execute? FYI running puppet 2.6.16 From nodes.pp: node basenode-core { $snmp_server = "10.0.0.10" include snmpd } node ''myserver.domain.com'' inherits basenode-core { $snmp_password = "mypassword" } Thanks, Doug F -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> Is there a way to export a $variable from a node so it can be read > when the node processes one of its inherited modules? Is there > something I can put in the inherited node like import $variable > before the included modules execute? > > FYI running puppet 2.6.16This one of the parts where node inheritance is really nasty and I wouldn''t use it. I would try to do it with classes, like: class basenode::core { $snmp_server = "10.0.0.10" include snmpd } node ''myserver.domain.com'' { $snmp_password = "mypassword" inherits basenode::core } Also I would try to do that with parametrized classes: class basenode::core($snmp_password) { class{''snmpd'': server => ''10.0.0.10'', password => $snmp_password } } node ''myserver.domain.com'' { class{''basenode::core'': snmp_password => "mypassword" } } you might also want to look into hiera, which can give you additional options on how to structure that. ~pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlFpeMcACgkQbwltcAfKi38m6QCfVVDG4FyZKyWjOb7JELuw8Gvf IPQAoJGkEpdXBbTqzgGKWeaCkSPFXYFi =KpJb -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Hiera is probably the best way to do that but not sure if it works in 2.6. Using an ENC is another possible way to achieve this. On 13 April 2013 10:10, Doug_F <dforster@part.net> wrote:> List > > I want to have a per server snmp password setup. When I set it up as below > and run the client it is unable to process the module because it cannot > find the $snmp_password. > > Is there a way to export a $variable from a node so it can be read when > the node processes one of its inherited modules? > Is there something I can put in the inherited node like import $variable > before the included modules execute? > > FYI running puppet 2.6.16 > > From nodes.pp: > node basenode-core { > $snmp_server = "10.0.0.10" > include snmpd > } > > node ''myserver.domain.com'' inherits basenode-core { > $snmp_password = "mypassword" > } > > Thanks, > Doug F > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On Friday, April 12, 2013 7:10:07 PM UTC-5, Doug_F wrote:> > List > > I want to have a per server snmp password setup. When I set it up as below > and run the client it is unable to process the module because it cannot > find the $snmp_password. > > Is there a way to export a $variable from a node so it can be read when > the node processes one of its inherited modules? > Is there something I can put in the inherited node like import $variable > before the included modules execute? > >Yes and no. Node variables of a given node are visible as unqualified variables in classes declared by that node, and in classes declared by those classes, etc.. In that sense, you don''t need to do anything special. On the other hand, node inheritance simply does not do what you want. In fact "inheritance" is a misleading term there: what it gives you is more like an aggregation of the whole "inherited" node and the whole "inheriting" node. The two node blocks'' scopes are completely separate. There is no way to refer to node variables other than via their simple names (they have no qualified names), so they are accessible only when they are in-scope and unshadowed.> FYI running puppet 2.6.16 > > From nodes.pp: > node basenode-core { > $snmp_server = "10.0.0.10" > include snmpd > } > > node ''myserver.domain.com'' inherits basenode-core { > $snmp_password = "mypassword" > } > >The classic technique for qualifying or overriding a declaration made somewhere else is to declare a subclass that overrides the target declaration (which must belong to the superclass). This is the nearly the whole purpose of class inheritance in Puppet; it should not be used where such an override is not an essential part of the declarations needed. These days, however, the usual recommendation is to separate your site and node data from your manifests. That way, you can look up and plug in the correct data in the first place, obviating any need for class inheritance. The old-school approach to this was the extlookup() function, which has been available since at least the 0.24.x series of Puppet. The newer, more flexible approach is Hiera, which is a builtin for Puppet 3, but an add-on to Puppet 2. You can also use an ENC to provide the needed data as top-scope variables. Class parameterization plays in this arena, too, but it doesn''t directly solve your problem. It provides one possible vehicle for communicating the needed data to your classes, but should you decide to use it (which I recommend against in Puppet 2) then you still have a class / node structure issue to solve. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.