Ask Your Question
0

How do I display a nice error message when puppet:///modules/mymodule/mysourcefile.txt does not exist

asked 2014-08-02 01:02:47 -0500

slapbass gravatar image

This feels like a beginner question so apologies to the experts out there reading this. Please skip to the last line of this post for the 'shortened version of this question'.

For my module, I believe there is a high likelihood the user may not copy a required source file to the module 'files' directory before applying the module. In this use case, we cannot version control the source file with the module due to constraints. As such, I would like to present a custom error message that clearly explains to the user what they need to do (e.g. You must download file X from Y and ensure it is copied to Z before doing a puppet run.)

I know that without this custom error message puppet will automatically throw an error when we try to first use the file. That said, I don't believe in this particular case the error message will be user friendly enough as it would look something like this:

Error: /Stage[main]/Mymodule::Install/File[/tmp/mydestinationfile.txt]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/mymodule/mysourcefile.txt

To an experienced puppet user this makes perfect sense but to a puppet novice they may initially scratch their head wondering where puppet:///modules/mymodule/mysourcefile.txt would be on the file system.

I tried a few things but where I came unstuck was on how to assert against a file in the convention puppet:///modules/mymodule/mysourcefile.txt since this is not a native file representation.

TL;DR How do I output a custom error message for a failed assertion that a source file exists? In other words, how do I display a nice error message when puppet:///modules/mymodule/mysourcefile.txt does not exist

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-04 07:18:18 -0500

mapa3m gravatar image

I'm not sure there's a clean way to replace that error message, aside from editing puppet/type/file/source.rb - and then you'll have to deploy the custom file to all the users. I think this is something to be solved by training and documentation rather than code.

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

Stats

Asked: 2014-08-02 01:02:47 -0500

Seen: 284 times

Last updated: Aug 04 '14