How do I define and use variables in 2.6.4?
Setting global variables worked in previous versions and I understand
this has changed, but am unsure how to make the following work.
site.pp
====================import "dev_nodes.pp"
node default {
include tmpfiles
}
dev_nodes.pp
====================node dev_nodes inherits default {
include unixbase::basepackages
}
node ''imagetest.example.com'' inherits dev_nodes {
$offset = 27
}
basepackages.pp in unixbase
====================
class unixbase::basepackages inherits unixbase {
package { "git-core": ensure => installed, }
# test
file { "/tmp/offset":
ensure => present,
content => $offset,
# <= this worked before $::offset does not work either
$main::offset
}
}
--
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 03/16/2011 04:37 PM, chris mague wrote:> How do I define and use variables in 2.6.4? > Setting global variables worked in previous versions and I understand > this has changed, but am unsure how to make the following work. > > site.pp > ====================> import "dev_nodes.pp" > node default { > include tmpfiles > } > > dev_nodes.pp > ====================> node dev_nodes inherits default { > include unixbase::basepackages > } > node ''imagetest.example.com'' inherits dev_nodes { > $offset = 27 > } > > basepackages.pp in unixbase > ====================> > class unixbase::basepackages inherits unixbase { > package { "git-core": ensure => installed, } > # test > file { "/tmp/offset": > ensure => present, > content => $offset, > # <= this worked before $::offset does not work either > $main::offset > } > } >Are you sure this ever worked? Because I sure hope not. It''s horrid. Try and make offset a class parameter of unixbase::basepackages. You can set it in each inheriting node using an override: node foo inherits default { Class["unixbase::basepckages"] { offset => 27 } } At least that''s how overriding works with class inheritance. I never saw any use in node inheritance, but I''d guess it works the same, no? 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 Mar 16, 9:03 am, Felix Frank <felix.fr...@alumni.tu-berlin.de> wrote:> On 03/16/2011 04:37 PM, chris mague wrote: > > > > > > > > > > > How do I define and use variables in 2.6.4? > > Setting global variables worked in previous versions and I understand > > this has changed, but am unsure how to make the following work. > > > site.pp > > ====================> > import "dev_nodes.pp" > > node default { > > include tmpfiles > > } > > > dev_nodes.pp > > ====================> > node dev_nodes inherits default { > > include unixbase::basepackages > > } > > node ''imagetest.example.com'' inherits dev_nodes { > > $offset = 27 > > } > > > basepackages.pp in unixbase > > ====================> > > class unixbase::basepackages inherits unixbase { > > package { "git-core": ensure => installed, } > > # test > > file { "/tmp/offset": > > ensure => present, > > content => $offset, > > # <= this worked before $::offset does not work either > > $main::offset > > } > > } > > Are you sure this ever worked? Because I sure hope not. It''s horrid. > > Try and make offset a class parameter of unixbase::basepackages. > You can set it in each inheriting node using an override: > > node foo inherits default { > Class["unixbase::basepckages"] { > offset => 27 > } > > } > > At least that''s how overriding works with class inheritance. I never saw > any use in node inheritance, but I''d guess it works the same, no? > > HTH, > FelixIt worked in 0.25 My main problem is trying to get the values set in the parameters in an external node classifier. This is the YAML being returned, but I can''t get at the offset paramater inside of my classes and was testing with variables like above since that had previously worked. --- name: imagetest.example.com parameters: offset: "27" classes: - unixbase::basepackages -- 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.