Ask Your Question

Get the absolute path to the modules directory

asked 2017-04-07 12:45:58 -0600

speramus gravatar image


I need to store a yaml file and load it with the loadyaml function. But loadyaml requires an absolute path. So, how do I reliably get it in the production and dev environment so that when puppet agentruns on a node it finds it?

It's my understanding that puppet agent will contact puppet master to get it. So it's the master that is supposed to know about the location of the file. Either way I seem to need an absolute path.

Thanks, Sergei

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-11 23:40:18 -0600

natemccurdy gravatar image

updated 2017-04-12 16:08:12 -0600

There is a function called get_module_path in stdlib that does exactly what you want:

I imagine something like this is what you're looking for:

# For Puppet 4
$yaml_file = "${module_name.get_module_path}/files/foo.yaml"

# For Puppet 3
$module_path = get_module_path($module_name)
$yaml_file   = "${module_name}/files/foo.yaml"
edit flag offensive delete link more

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-04-07 12:45:58 -0600

Seen: 176 times

Last updated: Apr 12 '17