Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to name a file based on a MD5 sum of certain characters. Such as $environment and $URL. So from a high-level what I'd want is something like md5("http://$environment/$url").

Does anyone know how I get make this happen? Is there a built in function like Crypt::MD5 that I can use? Or should I write a custom function for this?

share|improve this question

If you're not fixed on MD5 hashes, you could use the sha1 function. Otherwise you have to write your own function or you use the Ruby manifests (rather than the Puppet DSL) which are supported since Puppet 2.6.0.

share|improve this answer
Info about why you might want to reconsider MD5 as a checksum: Seems the prevailing opinion of those who know is don't implement anything new using MD5. – davey Aug 2 '10 at 9:00

As per what @tore said, it is actually not that hard to write these little functions and extend Puppet DSL a little.

If you still need this MD5 and/or SHA1 check sum generation functions, then you can have a look at what I was able to do so far:

I hope you will find some of these functions handy :)


share|improve this answer

It shouldn't be to difficult to create your own function: lib/puppet/parser/functions/sha1.rb

This files contains the function for sha1 which can be used in Puppet DSL. If you know a little programming, maybe you can submit a patch to the Puppet team to add support for MD5 ?

share|improve this answer
Indeed I've just submitted a patch for this, it is really simple to add but may not be a good idea given SHA1 is a better algorithm. – kaerast Aug 2 '10 at 11:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.