On Sun, Dec 6, 2009 at 2:55 AM, Peter Meier <peter.me...@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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.


Reply via email to