# variable precedence

**URL:** <https://forum.ansible.com/t/variable-precedence/37218>\
**Category:** Ansible Project\
**Created:** [October 13, 2022, 7:50am UTC](https://forum.ansible.com/t/variable-precedence/37218 "2022-10-13T07:50:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [October 13, 2022, 7:50am UTC](https://forum.ansible.com/t/variable-precedence/37218/1 "2022-10-13T07:50:39Z")

</div>

Working with roles I am trying to understand variable precedence a little better bases on this [list from the manual](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#understanding-variable-precedence).

on line 14 we have **play vars\_files**.

That means an entriy like

vars\_files: path/to/vars.yml or  
vars\_files: defaults.yml

inside the playbook that, later on, also lists the roles to run right?

I am asking because of …

> 1. playbook group\_vars/\*
> 2. playbook host\_vars/\*
> 3. play vars\_files

1. & 10 are **playbook** , 14 is **play**. I assume that means the same (vars mentioned or linked to in the playbook), or is there any differenece?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 13, 2022, 2:02pm UTC](https://forum.ansible.com/t/variable-precedence/37218/2 "2022-10-13T14:02:12Z")

</div>

playbook reffers to the file that contains the plays, plays refer to  
the ansible object that maps hosts to tasks. while many use the terms  
interchangably, they are not really the same thing.

playbook: a list of plays (normally a file)  
play: mappijng of hosts to tasks  
role: groupsing of tasks/templates/vars and files for reuse  
task: an action to be taken for a target host  
handler: task that is only invoked conditionally from notifying task  
returning a changed status

task list : file containing just tasks  
vars file: file containing yaml variable declarations (mapping/dictionary)
