-
-
Save weirdbricks/0551992d946956844caf043779818979 to your computer and use it in GitHub Desktop.
Validate YAML in ruby - useful for hiera
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/bash | |
# | |
# Efstathios Xagoraris <[email protected]> | |
# Validate YAML files using ruby | |
# | |
ruby=/usr/share/logstash/vendor/jruby/bin/jruby | |
if [ $# -eq 0 ] | |
then | |
echo "Please provide a yaml file as argument eg $0 file.yaml" | |
exit 1 | |
fi | |
$ruby -ryaml -e "YAML.parse(File.open('${1}'))" | |
if [[ $? -ne 0 ]] | |
then | |
echo "$1 is not valid YAML" | |
exit 1 | |
else | |
echo "$1 is a valid YAML" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment