3

I have a rancher-compose.yml file where I set the upgrade_strategy.start_first field using an environment variable like this:

  upgrade_strategy:
    start_first: ${START_FIRST}
    batch_size: 1

When running using the rancher-compose CLI, I get the following error:

ERRO[0000] Failed to open project origami-svcproxy: yaml: unmarshal errors:
  line 28: cannot unmarshal !!str `false` into bool 

When running in debug I see the following yaml:

  upgrade_strategy:
    batch_size: 1
    start_first: "false"  # <-- notice the surrounding quotes, missing from the rest of the variable replacements

How can I set this field dynamically?

David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125

1 Answers1

1

I had the same problem and used a different strategy to fix the issue. First step is to convert docker-compose.yml to a template, docker-compose.yml.tpl. Second, use template logic to fetch the value of the boolean variable.

  upgrade_strategy:
    start_first: {{ .Values.START_FIRST }}
    batch_size: 1

Reference: https://github.com/rancher/rancher-catalog/blob/v1.6-development/infra-templates/ipsec/9/docker-compose.yml.tpl#L21

leodotcloud
  • 1,830
  • 14
  • 15
  • Similar to my solution - since the rancher-compose ran from a makefile, I've created a template and then replaced the relevant values using sed – David Rabinowitz Jun 22 '17 at 05:50