Deployment Automation - Configuration Templates

1 Likes

Deploying applications is often as much about "updating configuration" as it is about deploying the physical files of the application itself. Configuration is used by applications at runtime  - and is often stored in files (property files, XML files, YAML files etc) and needs to be updated based on the environment in which the application is running. In order to support configuration updates Deployment Automation has a feature called Configuration Templates. I've not seen that many people make use of this feature so in this post we I look at an example of how to use them..

Configuration Templates are created at the Component level in Deployment Automation. To see how they work you can create a new component with an "environment property". In Deployment Automation 6.3 these properties are created by clicking on the Component's Properties tab and selecting ENVIRONMENT PROPDEFS. In the following screenshot I have added three examples properties for working with a database: "database.name, database.user, database.password".

da-templates-envprops.png

 Next you need to create a new Configuration Template. To do this click on TEMPLATES and CREATE a new template. In this example I have created a template called "config props" with entries for all the database settings:

da-templates-template.png

 Between the "@" symbols you should see reference to the properties that have been created, such as the "database.name" property - these will be replaced by the environment specific values at runtime. The other property "backup.dir" will be stored on the Resource being deploying to and you will need a little tweak to reference this in a bit.

Now you need a process to create this Configuration Template as a physical file and update it. First  click on the PROCESSES tab and CREATE a component process of type "Configuration Deployment" as below:

da-templates-createprocess.png

After you have SAVED the new process, navigate into it by clicking on its name. Then in the DESIGN of this process, drag on the step "Resource Tools -> Configuration Management -> Install Template". In this step's Properties on the right reference the name of the configuration file you are creating, e.g. "config.props".

da-templates-process.png

Next you need to do the tweak to include Resource properties - to do this open up and click on Hidden Properties at the bottom right. In the field "Environment Properties List" you should see "${environment/allProperties}", change this to read "${environment/allProperties},${resource/allProperties}" so it can resolve resource properties too. Note you could refer to the individual property "${resource/backup.dir}" but this way you are including any future Resource properties.

Next you need to add this component process to an application process as in the following:

da-template-appprocess.png

Finally, you need to add the Resource property to the appropriate Resources. To do this navigate to the resources you will be using and click on the the PROPERTIES tab and ADD PROPERTY as follows:

da-templates-resourceprop.png

Note in this example I am referring to other properties: the application and environment name. These will be automatically resolved at execution time.

Now when you execute this process you should see something similar to the following in the console output log of the process step:

da-template-examplerun.png

In this example you can see that the configuration file is created with the properties resolved correctly. The benefits of this approach is that you have the configuration file stored and versioned in Deployment Automation. However, if you have an existing configuration file that is already have under version control as a file you can also use the step "Utilities -> File Utils -> Replace Tokens" as this works in a similar way on existing files.

 

Labels:

How To-Best Practice
Comment List
Related
Recommended