summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-11-09 14:44:05 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-11-09 14:44:05 -0800
commit0bd973791f05f1d7f94e91b354015789b6b608dc (patch)
tree5e9124a028bb4eb300cfdce04725d52072f9c327
parent8c006684034c13719171672836edfc65bf02ebe9 (diff)
parentd8e82fb7bc9da6259b158804ae3d8343050c67aa (diff)
downloadvyos-cloud-init-0bd973791f05f1d7f94e91b354015789b6b608dc.tar.gz
vyos-cloud-init-0bd973791f05f1d7f94e91b354015789b6b608dc.zip
Merge the yaml/cloud config examples checking tool.
-rw-r--r--Makefile9
-rw-r--r--doc/examples/cloud-config.txt3
-rw-r--r--tests/configs/sample1.yaml1
-rwxr-xr-xtools/validate-yaml.py26
4 files changed, 35 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 88c90b9b..2a6be961 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt
index 04bb5df1..12bf2c91 100644
--- a/doc/examples/cloud-config.txt
+++ b/doc/examples/cloud-config.txt
@@ -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
diff --git a/tests/configs/sample1.yaml b/tests/configs/sample1.yaml
index 24e874ee..6231f293 100644
--- a/tests/configs/sample1.yaml
+++ b/tests/configs/sample1.yaml
@@ -50,4 +50,3 @@ runcmd:
byobu_by_default: user
-output: {all: '| tee -a /var/log/cloud-init-output.log'}
diff --git a/tools/validate-yaml.py b/tools/validate-yaml.py
new file mode 100755
index 00000000..eda59cb8
--- /dev/null
+++ b/tools/validate-yaml.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+"""Try to read a YAML file and report any errors.
+"""
+
+import sys
+
+import yaml
+
+
+if __name__ == "__main__":
+ bads = 0
+ 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))
+ bads += 1
+ if bads > 0:
+ sys.exit(1)
+ else:
+ sys.exit(0)