Hi David,
I've been using freemarker templates for this, and it works quite well, for
example:
brooklyn.config:
templates.install:
"https://some.server.com/nginx.conf.template":
templates/nginx.conf
Then using them in install.command, customize.command etc as follows:
cp ${INSTALL_DIR}/templates/nginx.conf /etc/nginx/
The templates themselves are standard Freemarker [1], for example to get at
a config property.
${config['management.https.port']?c}
you can even do stuff like iterate over hashes:
<#list config['jms.connectionfactories'] as factory>
<connection-factory name="${factory.name}" entries="java:/jms/${
factory.name}" connectors="${factory.connector!"in-vm"}"/>
</#list>
I can share an example with you if you like. (there are some existing
examples in the Brooklyn repos [2] [3] and others).
I'm sure this isn't the only way to achieve the desired result, it proved
compelling for me vs sed due to the easy iteration and manipulation.
/John
[1] - http://freemarker.org/docs/index.html
[2] -
https://github.com/apache/brooklyn-library/blob/master/software/nosql/src/main/resources/org/apache/brooklyn/entity/nosql/mongodb/mongodb_win.yaml
[3] -
https://github.com/apache/brooklyn-library/blob/master/software/database/src/main/resources/org/apache/brooklyn/entity/database/mssql/mssql.yaml
On Fri, 25 Mar 2016 at 17:29 David Bush <[email protected]>
wrote:
> Hi,
>
> As part of a blueprint I need to import some config files and inject
> values for parameters such as ip addresses gained from sensors or
> environment variables.
>
> I am currently using sed to replace parameters in the files which is great
> for one or two but I need to increase the replacements to support
> additional functions.
>
> I am looking to use templates.install to copy the files.
>
> Can anyone advise best practice way to do this? I looked for examples in
> the repos but searching for templates.install did not reveal much (to me).
> I can see sed being used elsewhere but nothing for multiple replacements.
> Guessing there must be a straight forward ${param}: param type method for
> doing this?
>
> Many thanks,
> David.
>
> --
> David Bush • Systems Integrator • Cloudsoft Corporation •
> http://www.cloudsoftcorp.com <http://www.cloudsoftcorp.com/>
> T: 07834 127195 • SKYPE: david.c.bush
>
>