Add a makefile yaml checking target

and fix the cases where the cc yaml
is not correct.
This commit is contained in:
Joshua Harlow 2012-11-07 21:00:33 -08:00
parent b55a63717f
commit e5011eeb34
4 changed files with 29 additions and 4 deletions

View File

@ -2,6 +2,10 @@ CWD=$(shell pwd)
PY_FILES=$(shell find cloudinit bin tests tools -name "*.py" -type f )
PY_FILES+="bin/cloud-init"
YAML_FILES=$(shell find cloudinit bin tests tools -name "*.yaml" -type f )
YAML_FILES+=$(shell find doc/examples -name "cloud-config*.txt" -type f )
all: test
pep8:
@ -23,11 +27,14 @@ clean:
rm -rf /var/log/cloud-init.log \
/var/lib/cloud/
yaml:
@$(CWD)/tools/validate-yaml.py $(YAML_FILES)
rpm:
./packages/brpm
deb:
./packages/bddeb
.PHONY: test pylint pyflakes 2to3 clean pep8 rpm deb
.PHONY: test pylint pyflakes 2to3 clean pep8 rpm deb yaml

View File

@ -355,8 +355,7 @@ rsyslog:
- ':syslogtag, isequal, "[CLOUDINIT]" /var/log/cloud-foo.log'
- content: "*.* @@192.0.2.1:10514"
- filename: 01-examplecom.conf
content: |
*.* @@syslogd.example.com
content: "*.* @@syslogd.example.com"
# resize_rootfs should the / filesytem be resized on first boot
# this allows you to launch an instance with a larger disk / partition

View File

@ -50,4 +50,3 @@ runcmd:
byobu_by_default: user
output: {all: '| tee -a /var/log/cloud-init-output.log'}

20
tools/validate-yaml.py Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env python
"""Try to read a YAML file and report any errors.
"""
import sys
import yaml
if __name__ == "__main__":
for fn in sys.argv[1:]:
sys.stdout.write("%s" % (fn))
try:
fh = open(fn, 'r')
yaml.safe_load(fh.read())
fh.close()
sys.stdout.write(" - ok\n")
except Exception, e:
sys.stdout.write(" - bad (%s)\n" % (e))