raphink
raphink

Reputation: 3665

Map puppet path to absolute path

I'm trying to write a new function for puppet which would take a puppet source path as argument, such as:

puppet:///modules/foo/some/dir

The function then needs to analyse this directory, so I need to figure out the absolute path to the directory, which depends on the environment, for example:

/srv/puppetmaster/stable/modules/foo/files/some/dir

What function can I use to achieve this?

Upvotes: 4

Views: 1386

Answers (2)

Michael Slade
Michael Slade

Reputation: 13877

From a persual of the puppet source, the impression I get is that if it were possible, it would require modifications to the puppet source code and it would be ugly.

So my response is, are you perhaps trying to solve the wrong problem?

If you want to convert a fileserver path to a master-local file path, that suggests that you want to write a function that uses data on the server normally only needed on the client. Why do you want to do this? Do you have files that are needed by both the master and the clients? (This sounds unlikely) Does that url actually need to be converted to a local file path at all?

Upvotes: 0

vengeance
vengeance

Reputation: 94

Not sure if there is an internal method / function to do this, but there still may be a couple of ways to achieve this.

  1. Check ENV for any puppet configurations.

  2. Make a system() call from your script - puppet can dump out configuration values for the module path:

    $ puppet master --configprint modulepath
    $ puppet agent --configprint modulepath
    

Upvotes: 1

Related Questions