]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/chef/libraries/persistent_token.rb
Remove remaining uses of "normal" attributes
[chef.git] / cookbooks / chef / libraries / persistent_token.rb
diff --git a/cookbooks/chef/libraries/persistent_token.rb b/cookbooks/chef/libraries/persistent_token.rb
new file mode 100644 (file)
index 0000000..8299e85
--- /dev/null
@@ -0,0 +1,20 @@
+require "digest"
+
+class Chef
+  module Mixin
+    module PersistentToken
+      def persistent_token(*args)
+        sha256 = Digest::SHA256.new
+        sha256.update(node[:machine_id])
+        args.each do |arg|
+          sha256.update(arg)
+        end
+        sha256.hexdigest
+      end
+    end
+  end
+
+  class Recipe
+    include Chef::Mixin::PersistentToken
+  end
+end