]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/chef/libraries/random_password.rb
Move chef extensions/patches to the chef cookbook
[chef.git] / cookbooks / chef / libraries / random_password.rb
diff --git a/cookbooks/chef/libraries/random_password.rb b/cookbooks/chef/libraries/random_password.rb
new file mode 100644 (file)
index 0000000..f8c6674
--- /dev/null
@@ -0,0 +1,9 @@
+class Chef
+  class Recipe
+    def random_password(length)
+      length.times.collect do
+        "!\#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~"[rand(91)].chr
+      end.join
+    end
+  end
+end