diff --git a/doc/source/template_guide/environment.rst b/doc/source/template_guide/environment.rst index 6a8e60b42e..abaf8d28b9 100644 --- a/doc/source/template_guide/environment.rst +++ b/doc/source/template_guide/environment.rst @@ -70,6 +70,28 @@ If the :file:`my_env.yaml` file from the example above had been put in the heat stack-create my_stack -P "some_parm=bla" -f my_tmpl.yaml +Global templates +---------------- +A global template directory allows files to be pre-loaded in the global +environment. A global template is determined by your cloud operator. +An entry in the user template takes precedence over the global environment. +OpenStack includes a default global template, but your cloud operator +can add additional template entries. + +The cloud operator can add new global templates by putting template +files in a configurable directory wherever the Orchestration engine runs. +The configuration variable is named ``template_dir`` and is found in the +``[DEFAULT]`` section of :file:`/etc/heat/heat.conf`. The default for +that directory is :file:`/etc/heat/templates`. Its contents are +combined in whatever order the shell delivers them when the service +starts up, which is the time when these files are read. +If the :file:`my_tmpl.yaml` file from the example below has been put in the +``template_dir``, other templates which we used to create stacks could +contain following way to include `my_tmpl.yaml` in it:: + + resourceA: + type: {get_file: "my_tmpl.yaml"} + Usage examples ~~~~~~~~~~~~~~ diff --git a/heat/common/config.py b/heat/common/config.py index 70307671da..63dc7de13c 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -96,6 +96,9 @@ engine_opts = [ cfg.StrOpt('environment_dir', default='/etc/heat/environment.d', help=_('The directory to search for environment files.')), + cfg.StrOpt('template_dir', + default='/etc/heat/templates', + help=_('The directory to search for template files.')), cfg.StrOpt('deferred_auth_method', choices=['password', 'trusts'], default='trusts', diff --git a/heat/tests/common.py b/heat/tests/common.py index 19bf07c987..92b8d3ae9b 100644 --- a/heat/tests/common.py +++ b/heat/tests/common.py @@ -102,9 +102,12 @@ class HeatTestCase(testscenarios.WithScenarios, project_dir = os.path.abspath(os.path.join(mod_dir, '../../')) env_dir = os.path.join(project_dir, 'etc', 'heat', 'environment.d') + template_dir = os.path.join(project_dir, 'etc', 'heat', + 'templates') cfg.CONF.set_default('environment_dir', env_dir) cfg.CONF.set_override('error_wait_time', None, enforce_type=True) + cfg.CONF.set_default('template_dir', template_dir) self.addCleanup(cfg.CONF.reset) messaging.setup("fake://", optional=True) diff --git a/releasenotes/notes/add-template-dir-config-b96392a9e116a2d3.yaml b/releasenotes/notes/add-template-dir-config-b96392a9e116a2d3.yaml new file mode 100644 index 0000000000..8e6144064e --- /dev/null +++ b/releasenotes/notes/add-template-dir-config-b96392a9e116a2d3.yaml @@ -0,0 +1,6 @@ +--- +features: + - Add `template_dir` to config. Normally heat has template directory + `/etc/heat/templates`. This change makes it more official. In the future, + it is possible to implement features like access templates directly from + global template environment.