diff --git a/lib/aquilon/worker/templates/base.py b/lib/aquilon/worker/templates/base.py index b18752306..6c7468a17 100644 --- a/lib/aquilon/worker/templates/base.py +++ b/lib/aquilon/worker/templates/base.py @@ -388,9 +388,17 @@ def _generate_content(self): lines.append("object template %s;" % self.template_name(self.dbobj)) lines.append("") - loadpath = self.loadpath(self.dbobj) - if loadpath: - pan_variable(lines, "LOADPATH", [loadpath]) + if self.loadpath(self.dbobj): + # If configuration option template_library_configured is true, define + # an ARCHETYPE variable with the host archetype and use it to initialize + # LOADPATH variable + if self.config.getboolean("panc", "template_library_configured"): + archetype_var_name = "ARCHETYPE" + pan_variable(lines, archetype_var_name, self.loadpath(self.dbobj), final=True) + # Define LOADPATH based on ARCHETYPE variabble + pan_variable(lines, "LOADPATH", [archetype_var_name], quoted=False) + else: + pan_variable(lines, "LOADPATH", [self.loadpath(self.dbobj)]) lines.append("") pan_assign(lines, "/metadata/template/branch/name", self.dbobj.branch.name)