Last active
April 20, 2020 06:10
-
-
Save xiii/96381e41f66e5cf6a72d to your computer and use it in GitHub Desktop.
Validate YAML in ruby - useful for hiera
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
#!/bin/bash | |
# | |
# Efstathios Xagoraris <sxagoraris@gmail.com> | |
# Validate YAML files using ruby | |
# | |
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
Looks much better! Thanks