You'll need to run this on the Server in Orgmapper, eg:
/opt/opscode/bin/orgmapper
orgmapper>> eval(::File.read("/path/to/code.rb"))
This is the code file you'll want to save
require 'json'
h = Hash.new {|h,k| h[k]=[]};
sql.select(:name, :org_id).from(:nodes).each {|n| h[n[:org_id]] << n[:name] }
h.map { |id, n| { ORGS.all.find { |o| o['guid'] == id }['name'] => n }}
h.dup.each { |id, n| h[ORGS.all.find { |o| o['guid'] == id }['name']] = h.delete(id) }
File.open('/tmp/nodes.json', 'w') { |f| f.write JSON.pretty_generate(h) }
Chef 12 moved everything to pgsql, so you can just query postgres
/opt/opscode/embedded/bin/psql -U opscode_chef -h 127.0.0.1
SELECT
n.name AS node,
o.name AS org
FROM nodes n
INNER JOIN orgs o ON n.org_id = o.id
GROUP BY
n.name,
o.name;