Ask Your Question

How to allow a source in a custom module? I.e. accept and use a URI that points to a file server mount point

asked 2017-10-23 13:33:49 -0600

jasons gravatar image

The file resource type supports the source attribute. This can be used to pull files from Puppet file server mount points. I.e. I could specify puppet:///mymount/folder/file.ext and the file resource will create a file using that file as a resource.

However what I want to do is read the contents of that file into a variable.

The file function supports reading of files into a variable, but only out of modules it seems, and not out of file server mount points.

Is there a way to add the source attribute to my own module or function and leverage Puppet's existing code for doing this?

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-25 03:57:14 -0600

David Schmitt gravatar image

updated 2017-10-25 03:57:35 -0600

On the server you can use file() (docs) to load content from the local filesystem. To the best of my knowledge, here is no such function I know of to process puppet:// URLs.

edit flag offensive delete link more


Is there any kind of documentation or guide for the underlying Ruby code? There's a source.rb file that gets used to process the URI, but my Ruby is pretty shallow. One would think one could use that source.rb file in the same way the `file` resource does.

jasons gravatar imagejasons ( 2017-10-25 11:42:09 -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: 2017-10-23 13:33:49 -0600

Seen: 34 times

Last updated: Oct 25 '17