Greetings,

I could use some clarity on node scope, class scope, and best practices.  I 
have the following:

# Node definition

if $hostname == 'mynode-dev' {
    $app_version = '1.0'
    include robin_dev
}

# Class definition 

class robin_dev {
    if $app_version == undef {
        $app_version = '0.5'
    }
    include robin_dev::install
}

class robin_dev::install {
    package {
        "app_name":                       ensure => $robin_dev::app_version;
    }
}


My intent is to set $app_version within my node definition.  If 
$app_version is not set there, I 'd like it to default to a version that is 
set within class robin_dev itself, which is 0.5 in the above example.

While the above example works as I just described, i'm not understanding 
how $robin_dev::app_version referenced in class robin_dev::install returns 
"1.0" when I its assigned in the node definition.  I initially assumed that 
class robin_dev would need to re-assign the variable within the class 
itself like this:

# Class definition 

class robin_dev {
    if $app_version == undef {
        $version = '0.5'
    } else {

                    $version = $app_version

    include robin_dev::install
}


 class robin_dev::install {
    package {
        "app_name":                       ensure => $robin_dev::version;
    }
}


 Any insights would be appreciated.  Thank you.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c51f4240-200f-425e-b6b5-abb3347bc9cf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to