Skip to content

Instantly share code, notes, and snippets.

@stefanlasiewski
Created July 2, 2014 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanlasiewski/e8074a3fb8a94fa81ea2 to your computer and use it in GitHub Desktop.
Save stefanlasiewski/e8074a3fb8a94fa81ea2 to your computer and use it in GitHub Desktop.
Parse all YAML files in my Hiera datadir
find /etc/puppet/hieradata/ -name "*.yaml" | while read file; do echo "file=$file"; ruby -e "require 'yaml'; YAML.load_file('$file')"; done
### Use case
[root@puppet3 hieradata]# find /etc/puppet/hieradata/ -name "*.yaml" | while read file; do echo "file=$file"; ruby -e "require 'yaml'; YAML.load_file('$file')"; done
file=/etc/puppet/hieradata/common.yaml
file=/etc/puppet/hieradata/virtual/vmware.yaml
file=/etc/puppet/hieradata/osfamily/Debian.yaml
file=/etc/puppet/hieradata/osfamily/RedHat.yaml
/usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 4, col 26: ` vmwaretools::working_dir: /opt/vmware' (ArgumentError)
from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/lib/ruby/1.8/yaml.rb:144:in `load_file'
from /usr/lib/ruby/1.8/yaml.rb:143:in `open'
from /usr/lib/ruby/1.8/yaml.rb:143:in `load_file'
from -e:1
[root@puppet3 hieradata]#
[root@puppet3 hieradata]# cat osfamily/RedHat.yaml
---
classes:
- stefan-yum
# TABS are bad
<TAB>vmwaretools::working_dir: /opt/vmware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment