0Pricing
Ansible Academy · Lesson

Extra Vars on the Command Line

Override values at runtime with -e.

Values at Runtime

Sometimes you want to pick a value when you launch a play, not bake it into a file. That is what extra vars are for. 🌟

The -e Flag

Pass extra vars with the -e (or --extra-vars) flag on ansible-playbook. Each one becomes a variable for the whole run.

ansible-playbook site.yml -e "env=prod"

All lessons in this course

  1. Defining & Using vars in a Play
  2. The {{ }} Substitution Syntax
  3. Extra Vars on the Command Line
  4. Where Variables Come From & Precedence
← Back to Ansible Academy