Last active
May 24, 2016 04:27
-
-
Save jaimegago/6de65aa1f2f632919f67467ba882dabe to your computer and use it in GitHub Desktop.
chef_lib_hash_to_string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This goes in <my_app_coobkook>/libraries/default.rb | |
class Chef | |
class Resource | |
def hash_to_s hash | |
hash.map do |k,v| | |
k.to_s + '=' + v.to_s | |
end.join("\n") + "\n" | |
end | |
end | |
end | |
### | |
## and this is how you use it in a recipe | |
file <path_to_file> do | |
content hash_to_s(my_hash) | |
end | |
# Say you have path_to_file='/tmp/myfile' | |
# and my_hash = { 'quote' => 'to be or not to be' } | |
# it would create a file /tmp/myfile which content would be quote=to be or not to be | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment