Skip to content

Instantly share code, notes, and snippets.

@logikal
Last active December 12, 2015 23:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save logikal/4839223 to your computer and use it in GitHub Desktop.
Save logikal/4839223 to your computer and use it in GitHub Desktop.
Get your Chef environment back to a pretty-printed hash. e.g. for use with vagrant.
require 'JSON'
require 'Chef'
require 'pp'
# Probably a better way to shell out, this was quick
# Interestingly, this gets typed out as a Chef::Environment, so you have to require 'Chef'
environment = JSON.parse(`knife environment show environmentname -Fj`)
# Pretty print your environment's hash.
# Suitable for use with vagrant!
pp environment.to_hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment