Skip to content

Instantly share code, notes, and snippets.

@dcarley
Created November 5, 2012 14:30
Show Gist options
  • Save dcarley/4017458 to your computer and use it in GitHub Desktop.
Save dcarley/4017458 to your computer and use it in GitHub Desktop.
Puppet eager/lazy evaluation test
define test_define(
$param_one = 'one',
$param_two = $param_one
) {
if $param_one == $param_two {
notice('eagar evaluation')
} else {
notice('lazy evaluation')
}
}
class test_class_noparams(
$param_one = 'one',
$param_two = $param_one
) {
if $param_one == $param_two {
notice('eagar evaluation')
} else {
notice('lazy evaluation')
}
}
class test_class_param(
$param_one = 'one',
$param_two = $param_one
) {
if $param_one == $param_two {
notice('eagar evaluation')
} else {
notice('lazy evaluation')
}
}
test_define { 'noparams': }
test_define { 'param':
param_one => 'ONE',
}
class { 'test_class_noparams': }
class { 'test_class_param':
param_one => 'ONE',
}
$ for i in $(seq 1 5); do puppet apply eval_test.pp; done
notice: Scope(Class[Test_class_noparams]): eagar evaluation
notice: Scope(Class[Test_class_param]): eagar evaluation
notice: Scope(Test_define[noparams]): eagar evaluation
notice: Scope(Test_define[param]): eagar evaluation
notice: Finished catalog run in 0.01 seconds
notice: Scope(Class[Test_class_noparams]): lazy evaluation
notice: Scope(Class[Test_class_param]): eagar evaluation
notice: Scope(Test_define[noparams]): lazy evaluation
notice: Scope(Test_define[param]): eagar evaluation
notice: Finished catalog run in 0.01 seconds
notice: Scope(Class[Test_class_noparams]): lazy evaluation
notice: Scope(Class[Test_class_param]): eagar evaluation
notice: Scope(Test_define[noparams]): lazy evaluation
notice: Scope(Test_define[param]): eagar evaluation
notice: Finished catalog run in 0.01 seconds
notice: Scope(Class[Test_class_noparams]): eagar evaluation
notice: Scope(Class[Test_class_param]): eagar evaluation
notice: Scope(Test_define[noparams]): eagar evaluation
notice: Scope(Test_define[param]): eagar evaluation
notice: Finished catalog run in 0.01 seconds
notice: Scope(Class[Test_class_noparams]): eagar evaluation
notice: Scope(Class[Test_class_param]): eagar evaluation
notice: Scope(Test_define[noparams]): eagar evaluation
notice: Scope(Test_define[param]): eagar evaluation
notice: Finished catalog run in 0.01 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment