0

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?

dartarrow
  • 1
  • 3

3 Answers3

2

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.

joschi
  • 20,747
  • 3
  • 46
  • 50
  • Info about why you might want to reconsider MD5 as a checksum: http://en.wikipedia.org/wiki/MD5#History_and_cryptanalysis. Seems the prevailing opinion of those who know is don't implement anything new using MD5. – gm3dmo Aug 02 '10 at 09:00
1

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

0

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 ?

tore-
  • 1,386
  • 2
  • 10
  • 18
  • 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. – WheresAlice Aug 02 '10 at 11:13