Skip to content

Latest commit

 

History

History
153 lines (127 loc) · 5.67 KB

README.md

File metadata and controls

153 lines (127 loc) · 5.67 KB

back to Commands

om interpolate

The interpolate command allows you to test template interpolation in isolation.

For example if you are modifying a product configuration template you can use om interpolate to verify that the generated config looks correct before running om configure-product.

Command Usage

Usage:
  om [OPTIONS] interpolate [interpolate-OPTIONS]

interpolates variables into a manifest

Application Options:
      --ca-cert=               OpsManager CA certificate path or value
                               [$OM_CA_CERT]
  -c, --client-id=             Client ID for the Ops Manager VM (not required
                               for unauthenticated commands) [$OM_CLIENT_ID]
  -s, --client-secret=         Client Secret for the Ops Manager VM (not
                               required for unauthenticated commands)
                               [$OM_CLIENT_SECRET]
  -o, --connect-timeout=       timeout in seconds to make TCP connections
                               (default: 10) [$OM_CONNECT_TIMEOUT]
  -d, --decryption-passphrase= Passphrase to decrypt the installation if the
                               Ops Manager VM has been rebooted (optional for
                               most commands) [$OM_DECRYPTION_PASSPHRASE]
  -e, --env=                   env file with login credentials
  -p, --password=              admin password for the Ops Manager VM (not
                               required for unauthenticated commands)
                               [$OM_PASSWORD]
  -r, --request-timeout=       timeout in seconds for HTTP requests to Ops
                               Manager (default: 1800) [$OM_REQUEST_TIMEOUT]
  -k, --skip-ssl-validation    skip ssl certificate validation during http
                               requests [$OM_SKIP_SSL_VALIDATION]
  -t, --target=                location of the Ops Manager VM [$OM_TARGET]
      --trace                  prints HTTP requests and response payloads
                               [$OM_TRACE]
  -u, --username=              admin username for the Ops Manager VM (not
                               required for unauthenticated commands)
                               [$OM_USERNAME]
      --vars-env=              load vars from environment variables by
                               specifying a prefix (e.g.: 'MY' to load
                               MY_var=value) [$OM_VARS_ENV]
  -v, --version                prints the om release version

Help Options:
  -h, --help                   Show this help message

[interpolate command options]
      -c, --config=            path for file to be interpolated
          --vars-env=          load variables from environment variables
                               matching the provided prefix (e.g.: 'MY' to load
                               MY_var=value) [$OM_VARS_ENV]
      -l, --vars-file=         load variables from a YAML file
      -v, --var=               load variable from the command line. Format:
                               VAR=VAL
          --path=              extract specified value out of the interpolated
                               file (e.g.: /private_key). The rest of the file
                               will not be printed.
      -o, --ops-file=          YAML operations files
      -s, --skip-missing       allow skipping missing params

Interpolation

Given a template file with a variable reference:

# config.yml
key: ((variable_name))

Values can be provided from a separate variables yaml file (--vars-file) or from environment variables (--vars-env).

To load variables from a file use the --vars-file flag.

# vars.yml
variable_name: some_value
om interpolate \
  --config config.yml \
  --vars-file vars.yml

To load variables from a set of environment variables, specify the common environment variable prefix with the --vars-env flag.

OM_VAR_variable_name=some_value om interpolate \
  --config config.yml \
  --vars-env OM_VAR

The interpolation support is inspired by similar features in BOSH. You can refer to the BOSH documentation for details on how interpolation is performed.

One significant difference from similar features in BOSH and Concourse fly is that om performs dual-pass interpolation. That is, the template is interpolated (including applying ops files) once, and then the output of that interpolation is interpolated again, using the same arguments (except for Ops Files, which are not necessarily idempotent).

This allows the use of mapping variables, variables that contain a value that is a variable in turn. Mapping variables are useful for mapping between programmatically-generated variable names such as those created by om config-template and om staged-director-config, and credentials that may be used in multiple places, such as database passwords.

Such config might look something like this:

cc:
  database-password: ((cc_database_password))
uaa:
  database-password: ((uaa_database_password))

In such cases, a vars-file like this can encode the relationship:

---
cc_database_password: ((sql_password))
uaa_database_password: ((sql_password))

Assuming the value of sql_password is available to the interpolation, it will be present in the final output, like so:

cc:
  database-password: actualsqlpasswordverysecure
uaa:
  database-password: actualsqlpasswordverysecure

This feature generally shouldn't interfere with interpolation as it would normally work in BOSH. If you encounter any situation where this difference is an unwelcome surprise, please open an issue; we were unable to think of any.