Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

3 Answers 3

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: en.wikipedia.org/wiki/MD5#History_and_cryptanalysis. Seems the prevailing opinion of those who know is don't implement anything new using MD5. –  davey Aug 2 '10 at 9:00
add comment

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: https://github.com/kwilczynski/puppet-functions

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

KW

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.