brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Heneveld <>
Subject Brooklyn Tip of the Day: Injecting Script Vars
Date Thu, 16 Nov 2017 10:54:48 GMT

Hi All-

I've noticed in a few blueprints using VanillaSoftwareProcess there is a 
pattern like this:

   - |
     some_command ${V1} ${V2}
   - $brooklyn:config("v1")
   - $brooklyn:config("v2")

This is handy and has its uses but note it doesn't play nice with 
special characters in variables.  For instance if a user says `v1: 
pa$$word` it won't do what you want.

It's usually better to use:

   V1: $brooklyn:config("v1")
   V2: $brooklyn:config("v2")
   some_command "${V1}" "${V2}"

Brookyn will bash-escape-for-double-quotes the values in `shell.env` -- 
so the above will work with any chars in `v1` and `v2`!  (Note you need 
the double quotes around the reference _to_ `"${V..}"` - that's what 
it's escaped for.)

Unfortunately `shell.env` is coarse-grained, it applies to all commands, 
and in particular needs to resolve as early as `pre.install.command` 
(don't put `RUN_DIR` in there for instance!) but for config like 
passwords etc it's the way to go.


PS.  Addition of config like 
`{pre.,,post.}{install,customize,launch}.shell.env` - to be overlaid on 
top of `shell.env` - would be easy and useful!

PPS.  I've also noticed augeas - - being used in more 
complex blueprints.  Very elegant way to manage config files.

View raw message