I have a definition where I am trying to include a class... class db_deploy::base { $build_user = "build" } define db_deploy::elements($db_deploy_version) { include db_deploy::base # Use $build_user here } When I attempt to access $build_user in the db_deploy::elements definition, puppet thinks it has no value. What am I doing wrong? Doug. -- 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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi> I have a definition where I am trying to include a class... > > class db_deploy::base { > $build_user = "build" > } > > define db_deploy::elements($db_deploy_version) { > include db_deploy::base > > # Use $build_user here > } > > When I attempt to access $build_user in the db_deploy::elements > definition, puppet thinks it has no value. What am I doing wrong?the definition of the variable is only in the scope of the class. However you can address it by direct name: $ cat foo.pp class a { $b = ''helo world'' } define c(){ include a notice("$a::b") } c{''d'': } $ puppet foo.pp notice: Scope(C[d]): helo world but you have to include the class, otherwise the class isn''t evaluated hence you can''t refer to its variables. cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAksbjY4ACgkQbwltcAfKi3/5dQCfZO3yputBjgzFSX23v62qYt7a TpkAnjjlHdwKtrdZRJABNKYOJPFMs4Y1 =SpBF -----END PGP SIGNATURE----- -- 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 Sun, Dec 6, 2009 at 2:55 AM, Peter Meier <peter.meier@immerda.ch> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi > >> I have a definition where I am trying to include a class... >> >> class db_deploy::base { >> $build_user = "build" >> } >> >> define db_deploy::elements($db_deploy_version) { >> include db_deploy::base >> >> # Use $build_user here >> } >> >> When I attempt to access $build_user in the db_deploy::elements >> definition, puppet thinks it has no value. What am I doing wrong? > > > the definition of the variable is only in the scope of the class. > However you can address it by direct name: > > $ cat foo.pp > class a { > $b = ''helo world'' > } > > define c(){ > include a > notice("$a::b") > } > > c{''d'': } > $ puppet foo.pp > notice: Scope(C[d]): helo world > > but you have to include the class, otherwise the class isn''t evaluated > hence you can''t refer to its variables.That''s not working for me Pete. class db_deploy::base { $build_user = "build" } define db_deploy::starterkit($db_deploy_version, $db_type="mysql") { include db_deploy::base file { "${dir_deploy}/${db_deploy_version}/${db_type}/${dir_starterkit}/${db_deploy_version}/ant.properties.${db_deploy::base::build_user}": content => template("db_deploy/starterkit/ant.properties.${build_user}"), require => File["${dir_deploy}/${db_deploy_version}/${db_type}/${dir_starterkit}/${db_deploy_version}"], } } Results in puppet telling me that the path doesn''t exist... because the value of ${db_deploy::base::build_user} is empty. I''ve also tried $db_deploy::base::build_user and got the same result. Doug. -- 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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> That''s not working for me Pete. > > class db_deploy::base { > $build_user = "build" > } > > define db_deploy::starterkit($db_deploy_version, $db_type="mysql") { > include db_deploy::base > file { > "${dir_deploy}/${db_deploy_version}/${db_type}/${dir_starterkit}/${db_deploy_version}/ant.properties.${db_deploy::base::build_user}": > content => > template("db_deploy/starterkit/ant.properties.${build_user}"), > require => > File["${dir_deploy}/${db_deploy_version}/${db_type}/${dir_starterkit}/${db_deploy_version}"], > } > } > > Results in puppet telling me that the path doesn''t exist... because > the value of ${db_deploy::base::build_user} is empty. I''ve also tried > $db_deploy::base::build_user and got the same result.$ cat foo.pp class db_deploy::base { $build_user = ''helo world'' } define db_deploy::starterkit(){ include db_deploy::base notice("${db_deploy::base::build_user}") } db_deploy::starterkit{''d'': } $ puppet foo.pp notice: Scope(Db_deploy::Starterkit[d]): helo world Tested on 0.24.8 and 0.25.1 Did I miss a something due to not yet enough coffee? Why do I not see the class dependent variable call in your example? Copy&Paste error? cheers pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkscrbUACgkQbwltcAfKi3/tNACeIpHrw84sSEQdrc9m1oue0o1P Z+wAn0m1sBK/9TP7P2TmsUSBwlBh3wWX =1pcE -----END PGP SIGNATURE----- -- 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.