New Reply


I'm trying to set some variables in the web.config / app.config of a number of components (12 different components, each will have some common settings in the web/app config files - seems like Templates are the best way to do it, but open to suggestions).

The problem I'm having is that I can't get Templates working at all. Under Otter > Assets > Templates, i hit "create template", enter the name "Config", and hit Save. That appears to save the template, and I can click the template name to open it. In the dialog that opens though, I see the following text:

module Config



Which seems fine. However, I also see a warning:
There were one or more errors processing your script:
[Error] Line 1: Unexpected keyword.

And I can't switch to the visual editor.

If I change the word 'module' to 'template' and hit 'validate plan', it validates OK, and I can switch to the visual editor. I can then add operations to the template. But, when I hit 'save', it won't let me save, and gives more errors.

Is there a basic example somewhere of what a Template file should look like?



Product: Otter
Version: 1.7.2

It sounds like you intend to use "Text Templates"
( as opposed to "Templates" which are actually plan templates (and are being renamed to modules in order to avoid this exact type of confusion).

Apparently some of the script generation code used in drag-drop to text-mode conversion leaked into that release by accident - I will file that as a bug to get that fixed as plan templates should pass text-mode validation when written as either "module" or "template".

Hey Tod,

Thanks for the response!

I'm not 100% sure if Text Templates is what I'm looking for, although I could be wrong.

It looks like the Text Templates will work if the full config file is stored as a Text Template Asset within Otter. The scenario I have is e.g.:

  • 4 different web applications
  • Most of the web.config is specific to the individual web application - things like HTTP handlers and modules
  • Most of the items in the <appSettings> element are shared across the 4 applications though - connection strings / similar

The way we manage this currently (without Otter) is using an external config file. So in our web.config we have:

<appSettings file="C:\Shared\Config\File\Path.config"> </appSettings>

That shared config file can then be referenced by the 4 web applications.

One option I considered with Otter was to replicate that by having a 'Shared' server role which is responsible for creating the shared config file - that's easy enough using the ensure file exists / ensure app settings operations. However, I couldn't find a way, within Otter, to manipulate the individual web.config files to add the path to that file in the <appSettings> element.

I then started thinking about doing it using templates / modules. I figured I would have a template which contained a number of 'ensure app setting' operations, which I would apply as part of the configuration for each web application role. Then the settings would be applied to the web.config for each application, rather than using the shared config file.

Does what I'm trying to do here / my thought processes make sense?



You are correct, I was assuming you wanted to store the configuration file in Otter which is what text templates were designed for (), but if you don't want to do that then the Plan Template (module) with the whole lot of Ensure-AppSettings is a way to go.

If they are all key/value pairs you can go one step further:

set %AppSettings = %(key1: value1, key2: value2);

foreach $Key in @MapKeys(%AppSettings)
		Key: $Key,
		File: whatever,
		Value: %AppSettings.$Key

Hey Tod,

Thanks for the answer and apologies for not getting back to you sooner...

I see a new version of Otter is now available with the fixes included, so I'll try that out and see what happens.

Thanks for the great support!


Answer Details


Post Reply