diff --git a/schema.yaml b/schema.yaml index 47e957b..27901a9 100644 --- a/schema.yaml +++ b/schema.yaml @@ -4,6 +4,7 @@ mapping: # Global configuration of computing nodes. "images": type: map + required: true mapping: "default": type: str @@ -38,6 +39,7 @@ mapping: # Resource group definitions. "deployment": type: map + required: true mapping: "=": type: map @@ -74,17 +76,21 @@ mapping: - m1.xxlarge "start": type: date + required: false format: "%Y-%m-%d" "end": type: date + required: false format: "%Y-%m-%d" "group": type: str + required: true "image": type: str required: false "volume": type: map + required: false 'mapping': "size": type: int @@ -99,6 +105,7 @@ mapping: type: bool "cgroups": type: map + required: false 'mapping': "mem_limit_policy": type: str @@ -112,3 +119,4 @@ mapping: min: 1024 "docker": type: bool + required: false diff --git a/synchronize.py b/synchronize.py index 5af1112..7354742 100644 --- a/synchronize.py +++ b/synchronize.py @@ -592,6 +592,18 @@ def template_userdata( rendering the template. """ vars_files = frozenset(vars_files) + + environment = Environment( + loader=FileSystemLoader(user_data_file.parent), + undefined=StrictUndefined, + ) + template = environment.get_template( + user_data_file.name, + ) + + group_defaults = { + "docker": False, + } vars_from_files = ( reduce( lambda x, y: x.update(y), @@ -601,19 +613,13 @@ def template_userdata( else {} ) - environment = Environment( - loader=FileSystemLoader(user_data_file.parent), - undefined=StrictUndefined, - ) - template = environment.get_template( - user_data_file.name, - ) + variables = {} + for vars_group in (group_defaults, config, group_config, vars_from_files): + variables.update(vars_group) return template.render( name=name, - **config, - **group_config, - **vars_from_files, + **variables, ) diff --git a/tests.py b/tests.py index c0ebfef..7992d89 100644 --- a/tests.py +++ b/tests.py @@ -1440,6 +1440,7 @@ def test_template_userdata() -> None: owner: root:root path: /etc/configuration_file permissions: "0644" + docker: {{ docker }} """ )[1:] @@ -1481,6 +1482,7 @@ def test_template_userdata() -> None: owner: root:root path: /etc/configuration_file permissions: "0644" + docker: False """ )[1:-1] assert templated == expected