Ask Your Question

How I catch the name of puppet module?

asked 2017-03-23 07:51:37 -0600

Willian gravatar image

When I need to catch the module name, I use this way

# /etc/puppetlabs/code/environments/production/modules/xpto/manifests/init.pp
class xpto {
   notify {"Module name is ${name}":}      # it's work! print xpto

but, when I have a others class I don't know how I catch only the principal name


# /etc/puppetlabs/code/environments/production/modules/xpto/manifests/ssh.pp
class xpto::ssh {
  notify {"Module name is ${name}":}  # Here is my problem! How I print only the principal name? xpto.
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-03-23 10:31:47 -0600

DarylW gravatar image

updated 2017-03-23 10:32:41 -0600

Are you looking for the compiler-variable $module_name?

Compiler variables

These variables are set in every local scope by the compiler during compilation. They are mostly useful when implementing complex defined types.

These are not available in the $facts hash.

These variables are always defined (by the standards of the strict_variables setting), but their value is undef whenever no other value is applicable.

$module_name — the name of the module that contains the current class or defined type.

$caller_module_name — the name of the module in which the specific instance of the surrounding defined type was declared. This is only useful when creating versatile defined types which will be re-used by several modules.

edit flag offensive delete link more


\o/ Excellent!!!! It was exactly what I needed.... thanks very much!

Willian gravatar imageWillian ( 2017-03-23 11:32:09 -0600 )edit

Glad I could help! If this answers your question, can you hit the 'green check' to the left to accept the answer? It helps other people find the solution in the future!

DarylW gravatar imageDarylW ( 2017-03-24 07:01:17 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-03-23 07:51:37 -0600

Seen: 180 times

Last updated: Mar 23 '17