Last active
April 6, 2017 15:13
-
-
Save kam1kaze/d70d7e759429ab26cdb43014aa99c94e to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require 'yaml' | |
def parse_yaml(cl, align = '') | |
puts align + cl | |
reclass_dir = '/srv/salt/reclass' | |
yaml_file = if cl =~ /\.yml$/ | |
cl | |
elsif File.exist?(reclass_dir + '/classes/' + cl.tr('.', '/') + '/init.yml') | |
reclass_dir + '/classes/' + cl.tr('.', '/') + '/init.yml' | |
else | |
reclass_dir + '/classes/' + cl.tr('.', '/') + '.yml' | |
end | |
data = YAML.load_file(yaml_file) | |
if data.key?('classes') | |
align = align + ' ' | |
data['classes'].each do |nested_class| | |
parse_yaml(nested_class, align = align) | |
end | |
end | |
end | |
parse_yaml(ARGV[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment