]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/tools/libraries/random_password.rb
Add a bunch more cookbooks
[chef.git] / cookbooks / tools / libraries / random_password.rb
diff --git a/cookbooks/tools/libraries/random_password.rb b/cookbooks/tools/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