Ask Your Question
0

How I catch the name of puppet module?

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

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

Example:

# /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
0

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

DarylW gravatar image

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

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

Comments

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

Willian gravatar imageWillian ( 2017-03-23 11:32:09 -0500 )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 -0500 )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

Stats

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

Seen: 24 times

Last updated: Mar 23