modules/foo/manifests/init.pp
class foo {
define bar() {
notice("**********************************************")
notice("Calling: foo::bar")
notice("module_name: $module_name")
notice("caller_module_name: $caller_module_name")
}
}
modules/baz/manifests/init.pp
define bar() {
notice("**********************************************")
notice("Calling ::bar")
notice("module_name: $module_name")
notice("caller_module_name: $caller_module_name")
}
class baz {
define bar() {
notice("**********************************************")
notice("Calling baz::bar")
notice("module_name: $module_name")
notice("caller_module_name: $caller_module_name")
}
include foo
foo::bar { 'test': }
baz::bar { 'test': }
::bar { 'test': }
}
実行
$ puppet apply --modulepath=./modules -e 'include baz'
notice: Scope(Foo::Bar[test]): **********************************************
notice: Scope(Foo::Bar[test]): Calling: foo::bar
notice: Scope(Foo::Bar[test]): module_name: foo
notice: Scope(Foo::Bar[test]): caller_module_name: baz
notice: Scope(Baz::Bar[test]): **********************************************
notice: Scope(Baz::Bar[test]): Calling baz::bar
notice: Scope(Baz::Bar[test]): module_name: baz
notice: Scope(Baz::Bar[test]): caller_module_name: baz
notice: Scope(Bar[test]): **********************************************
notice: Scope(Bar[test]): Calling ::bar
notice: Scope(Bar[test]): module_name: baz
notice: Scope(Bar[test]): caller_module_name: baz
notice: Finished catalog run in 0.04 seconds
- $module_name: 定義元モジュール。グローバルに定義されている場合は、呼び出し元モジュール。
- $caller_module_name: 呼び出し元モジュール。
という感じかな。Language: Facts and Built-in Variables の Variables Set by the Parser に書いてある通りと言えばその通りだけど、こうやって動かしてみないとぴんと来なかった。