Ask Your Question

Is it appropriate to have commands in your params.pp class

asked 2016-09-22 07:20:53 -0600

puser gravatar image

updated 2016-09-22 08:13:56 -0600


I have a puppet module that ensures that an rpm is installed. If it is not installed it will install it in a default location (prefix). If it is installed it will make sure that the rpm is installed correctly with all correct files in either the default directory or the directory that was specified with the relocate option when the rpm was installed. I need to be able to check where the rpm was installed in my module.

In my params.pp class I am running a command to identify the location of the install

$cmd1 = "rpm -qa --queryformat '%{FILENAMES}' anf_jvmtop"
$specified_install_path = inline_template("<%= %x{$cmd1} %>")
if $specified_install_path == '' {
    $base = "/path"
else {
    $base = $specified_install_path

This basically returns the $base which is the prefix of the install like 'usr/bin' or wherever the user installed it.

Is this an appropriate usage of params.pp? I am rather new to puppet and every params.pp class I see has simple facts displayed. I thought about using an external fact but I don't want to have to put those on the puppet master and I think there is a simpler solution.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-09-22 08:20:02 -0600

No, don't do that. Functions like the inline_template function run on the Puppet Master, not the Puppet Agent. So $specified_install_path will tell you about a path on your Puppet Master, unless you're doing Masterless Puppet.

The normal way to do this is would be to use a custom fact.

edit flag offensive delete link more


So if I write a fact and put it in facts.d, how do I reference that in my other manifests?

puser gravatar imagepuser ( 2016-09-22 08:31:49 -0600 )edit

You can reference it in the $facts hash as $facts['myfact'] (preferred in Puppet 4), or in Puppet 3 as $::myfact.

Alex Harvey gravatar imageAlex Harvey ( 2016-09-22 09:32:48 -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: 2016-09-22 07:20:53 -0600

Seen: 64 times

Last updated: Sep 22 '16