Inject a part of YAML from a deployment manifest to a bosh release template


Maros Spak
 

My application uses configuration file in YAML format. Is there a way I can directly inject YAML from the manifest file to the template in BOSH release?

For example, let's say that in my deployment manifest are following properties
item1:
subitem1: foo
subitem2:
subsubitem1: foo
item2:
subitem1: foo
subitem2: foo
subitem3: foo
...
(structure of the item isn't always the same).

In a template for configuration file I want to use something like <%= p("item") %>, but I want it to just return the same YAML format.
Maybe I could loop through each of the items and their subitems (and their subsubitems...) but I am not really sure how.


Dmitriy Kalinin
 

you can do <%= YAML.dump(p("item")) %> inside erb template. enter it as usual into the manifest.

Sent from my iPhone

On Oct 20, 2016, at 8:04 AM, Maros Spak <slowbackspace(a)gmail.com> wrote:

My application uses configuration file in YAML format. Is there a way I can directly inject YAML from the manifest file to the template in BOSH release?

For example, let's say that in my deployment manifest are following properties
item1:
subitem1: foo
subitem2:
subsubitem1: foo
item2:
subitem1: foo
subitem2: foo
subitem3: foo
...
(structure of the item isn't always the same).

In a template for configuration file I want to use something like <%= p("item") %>, but I want it to just return the same YAML format.
Maybe I could loop through each of the items and their subitems (and their subsubitems...) but I am not really sure how.


Maros Spak
 

Almost... My configuration file template looks like this
items:
(space space)<%= YAML.dump(p("items")) %>

turns into:
items:
(space space)---
item1:
subitem1: foo
...

I need it with the right indentation and most likely without "---". Is it possible?


Dmitriy Kalinin
 

i would recommend following pattern where entire file is outputted at once. example: https://github.com/cloudfoundry-incubator/bosh-aws-cpi-release/blob/master/jobs/aws_cpi/templates/cpi.json.erb

this avoids tons of formatting, escaping issues.

Sent from my iPhone

On Oct 20, 2016, at 8:34 AM, Maros Spak <slowbackspace(a)gmail.com> wrote:

Almost... My configuration file template looks like this
items:
(space space)<%= YAML.dump(p("items")) %>

turns into:
items:
(space space)---
item1:
subitem1: foo
...

I need it with the right indentation and most likely without "---". Is it possible?