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: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,
envreturns an empty string"". - Use a default to avoid empty strings in commands or expressions that require a value.
envreads the process environment at evaluation time. Changes to the environment after the playbook starts are not visible.