Quiz Entry - updated: 2026.11.05
A group variable says package: httpd, the play's vars say package: nginx, and you run ansible-navigator run site.yml -e package=lighttpd. Which value is used, and why?
lighttpd. Extra variables given with -e / --extra-vars have the highest priority and override every other definition of the same name.
Walking up the ladder:
- The inventory's group variable sets
httpd. That is the lowest level. - The play's
varsblock setsnginx. Play variables beat inventory variables, songinxwould win so far. -e package=lighttpdis an extra variable. Nothing outranks it, solighttpdis used.
Without -e, the result would be nginx. This is also why -e is useful for one-off overrides ("deploy version 2.3 just this once") without editing any file. The flip side: a value forced with -e cannot be changed by anything inside the playbook, which can surprise you if you forget you passed it.
Go deeper:
Defining variables at runtime (official docs) โ
key=value, JSON and@fileforms of--extra-vars.