Config Loading

The configuration for a particular stack is built up by Sugarkube searching for and merging different YAML files. You may be aware that stacks are defined with the following settings:

name: dev
provider: aws
provisioner: kops
account: dev        # values don't need to be unique
region: eu-west-1
profile: infra
cluster: dev1

Each of these is used to build up the paths to files that Sugarkube will load and merge to create the final config for a given stack.

The search algorithm is as follows:

  1. Enter each directory defined in the stack’s provider_vars_dirs setting (and in the order they’re defined in) and look for a directory with the name of the stack’s provider.
  2. Load any with any of the following basenames (in this order) with an extension .yaml, ignoring duplicates:
    1. The literal string values (lowest precedence)
    2. The value of the provider setting
    3. The value of the provisioner setting
    4. The value of the account setting
    5. The value of the profile setting
    6. The value of the cluster setting
    7. The value of the region setting
    8. The literal string accounts (the local provider doesn’t do this)
    9. The literal string profiles
    10. The literal string clusters (highest precedence)
  3. Search for any directories with the above names (and no .yaml extension) in that order. For each one found, enter it and repeat steps 2 and 3.

While simple, this algorithm is the key to much of Sugarkube’s flexibility for handling different configs, allowing large sections to be shared or overridden in different ways.

To see the exact paths Sugarkube is searching for run Sugarkube with logging enabled (-l info)

Viewing a stack’s merged config

The above algorithm provides flexibility but does make it a bit less clear what the final config for a stack will be. To help with that Sugarkube has a cluster vars command that will traverse the configured provider vars dirs merging configs. It will then print out the merged config so you can inspect it. It has various options for suppressing or selecting output to make it easier to see only what you’re interested in.