Rancher CLI and answers.yaml for rancher app install

I am investigating Rancher CLI and its usage possibilities.

...

  # Install the redis template and specify an answers file location
  $ rancher app install --answers /example/answers.yaml redis appFoo

...

Usage:
  rancher apps install [OPTIONS] [TEMPLATE_NAME/TEMPLATE_PATH, APP_NAME]

Options:
   --answers value, -a value    Path to an answers file, the format of the file is a map with key:value. This supports JSON and YAML.
   --values value               Path to a helm values file.
   --namespace value, -n value  Namespace to install the app into
   --set value                  Set answers for the template, can be used multiple times. Example: --set foo=bar
   --version value              Version of the template to use
   --no-prompt                  Suppress asking questions and use the default values when required answers are not provided
   --helm-timeout value         Amount of time for helm to wait for k8s commands (default is 300 secs). Example: --helm-timeout 600 (default: 300)
   --helm-wait                  Helm will wait for as long as timeout value, for installed resources to be ready (pods, PVCs, deployments, etc.). Example: --helm-wait

How would the answers.yaml look like? Do I have to provide an answers.yaml that is basically the answers.yaml from a Rancher Helm App? Or does it have a different syntax? One could provide a file with key-value pairs that reference the variables in the original answers.yaml of the Rancher Helm app, so I don’t know if a full answers.yaml like the one provided in the Rancher Helm App is necessary.

If there would be some template and/or example of an answers.yaml that is actively being used in this way, I would appreciate that.

Hello,

The answers.yaml should be a yaml or json file that corresponds to the questions.yaml , containing any key that you do not want to use the default for. A quetions.yaml is a file that rancher uses in our charts. This file contains questions that correspond to variables from the values.yaml that we choose to expose. The key is equal the variable. For example, the variable abcd.efg, would be as follows in the answers.yaml:

abcd:
    efg: myvalue

For a more in depth look at how we handle charts, see: https://github.com/rancher/rancher/wiki/Understanding-How-Rancher-Configures-Helm-Charts

This link should also explain your options beyond using an answers.yaml. Hope this helps!

Thanks for the response.

Yes, I have created a Rancher Helm App, containing a questions.yaml that I manually fabricated. I just wonder if the answers.yaml for the Rancher CLI is expected to be exactly the same way as the actual answers.yaml from the Chart, except with changed values.

Basically:
Could I theoretically (even though it would be non-sensical) copy the answers.yaml from the Rancher Helm App and pass it as an argument to the Rancher CLI, so that it gets recognized as expected?

Are you referring to the yaml produced in the UI for launching apps when you select “Edit as YAML”?

No, I mean I actually created a Helm App by hand and have written a questions.yaml from scratch, put it into the Helm App and thereby upgrading it to a Rancher App. The questions.yaml is working fine in the UI.

Could I theoretically, even if it does not make sense, copy this questions.yaml and provide it as an argument when setting up this Rancher Helm App with the Rancher CLI?

When you say a helm app by hand you mean you put a questions.yaml in your chart? When you say “setting up this Rancher Helm App with the Rancher CLI” do you mean you’re installing it?

Putting a questions.yaml in a Helm chart makes it a Rancher Helm chart.

Yes, I mean installing it with the Rancher CLI.