Created
June 10, 2014 00:42
-
-
Save kelseyhightower/74392074a24ee78a99d1 to your computer and use it in GitHub Desktop.
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
#!/bin/ruby | |
require 'yaml' | |
raw_data = | |
%Q{ | |
apps: | |
appname: | |
workgroup1: | |
data: | |
foo: bar | |
zed: zot | |
ding: dong | |
hosts: | |
- vm01 | |
- vm02 | |
workgroup2: | |
data: | |
foo: bar1 | |
zed: zot1 | |
ding: dong1 | |
hosts: | |
- vm03 | |
- vm04 | |
} | |
data = YAML.load(raw_data) | |
data["apps"]["appname"].keys.each do |key| | |
puts("#Workgroup: #{key}") | |
data["apps"]["appname"][key]["hosts"].each do |host| | |
data["apps"]["appname"][key]["data"].each do |key, value| | |
puts("#{host}:#{key}:#{value}") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment