Map of the puppet path to the absolute path

I am trying to write a new function for a puppet that will take the path of the parent source as an argument, for example:

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

Then the function should analyze this directory, so I need to find 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?

+4
source share
2 answers

Not sure if there is an internal method / function for this, but there can be several ways for this.

  • Check ENV for any puppet configurations.

  • Calling system () from your script - a puppet can infer configuration values ​​for the module path:

     $ puppet master --configprint modulepath $ puppet agent --configprint modulepath 
+1
source

From the point of view of the puppet source, the impression I get is that if it were possible, it would require changes to the puppet source code, and that would be ugly.

So my answer is: maybe you are trying to solve the wrong problem?

If you want to convert the path to the file server to the path to the master-local file, this assumes that you want to write a function that uses the data on the server, usually only needed by the client. why do you want to do this? Do you have the files you need for both the wizard and the clients? (This sounds unlikely) Do I need to actually translate this URL into a local file path?

0
source

Source: https://habr.com/ru/post/1403829/


All Articles