Skip to main content
env(name) reads the environment variable name and returns its value. An optional second argument provides a fallback when the variable is not set.

Signature

Example

Configure the deployment target from the CI environment, with a safe fallback for local development:
On CI, CI_REGISTRY is set to the real registry. Locally, images are pushed to localhost:5000.

Notes

  • When called with one argument and the variable is not set, env returns an empty string "".
  • Use a default to avoid empty strings in commands or expressions that require a value.
  • env reads the process environment at evaluation time. Changes to the environment after the playbook starts are not visible.