From 455422ddd5152679eb8df5554e371dbcf2c28f27 Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 2 Jun 2014 12:02:29 -0700 Subject: static site: better message for wrong location type. --- puppet/modules/site_static/manifests/location.pp | 6 ++++-- puppet/modules/site_static/templates/apache.conf.erb | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/puppet/modules/site_static/manifests/location.pp b/puppet/modules/site_static/manifests/location.pp index 9c749b00..ce2af9af 100644 --- a/puppet/modules/site_static/manifests/location.pp +++ b/puppet/modules/site_static/manifests/location.pp @@ -1,13 +1,15 @@ define site_static::location($path, $format, $source) { $file_path = "/srv/static/${name}" + $allowed_formats = ['amber','rack'] if $format == undef { fail("static_site location `${path}` is missing `format` field.") } - if ! member(['amber','rack'], $format) { - fail("Could not understand static_site location format `${format}`.") + if ! member($allowed_formats, $format) { + $formats_str = join($allowed_formats, ', ') + fail("Unsupported static_site location format `${format}`. Supported formats include ${formats_str}.") } if ($format == 'amber') { diff --git a/puppet/modules/site_static/templates/apache.conf.erb b/puppet/modules/site_static/templates/apache.conf.erb index a16d51f4..07ac481d 100644 --- a/puppet/modules/site_static/templates/apache.conf.erb +++ b/puppet/modules/site_static/templates/apache.conf.erb @@ -82,10 +82,12 @@ <%- location_path = location['path'].gsub(%r{^/|/$}, '') -%> <%- directory = location_directory(name, location) -%> <%- local_vars = {'location_path'=>location_path, 'directory'=>directory, 'location'=>location, 'name'=>name} -%> +<%- template_path = File.join(File.dirname(__FILE__), location['format']) + '.erb' -%> +<%- break unless File.exists?(template_path) -%> ## ## <%= name %> (<%= location['format'] %>) ## -<%= scope.function_templatewlv([File.join(File.dirname(__FILE__), location['format']) + '.erb', local_vars]) %> +<%= scope.function_templatewlv([template_path, local_vars]) %> <%- end -%> -- cgit v1.2.3