将多行环境变量注入BOSH部署属性

时间:2017-06-29 21:00:22

标签: ruby yaml erb cf-bosh

假设我有BOSH部署

name: some-name
director_uuid: some-uuid
releases:  
compilation:
 ....
resource_pools:
 ...
networks:
 ...
jobs:
 - name: deployment_name
  instances: 1
  templates:

  resource_pool: ...
  networks: ..
  my_prop: "<%= ENV['MY_ENV_VAR'] %>"

如何注入多行MY_ENV_VAR值,以便在目标部署中正确呈现格式(换行符)?

使用my_prop的版本在这样的引擎下使用它

 <%= p('my_prop') %>

1 个答案:

答案 0 :(得分:1)

您可以使用YAML literal_block功能| [1]

name: some-name
director_uuid: some-uuid
releases:  
compilation:
 ....
resource_pools:
 ...
networks:
 ...
jobs:
 - name: deployment_name
  instances: 1
  templates:

  resource_pool: ...
  networks: ..
  my_prop: |
      "<%= ENV['MY_ENV_VAR'] %>"

[1] https://learnxinyminutes.com/docs/yaml/