Skip to content

Instantly share code, notes, and snippets.

@igordcsouza
Last active September 26, 2018 11:04
Show Gist options
  • Save igordcsouza/74e7008922ae8c3353c835d6fd27d8da to your computer and use it in GitHub Desktop.
Save igordcsouza/74e7008922ae8c3353c835d6fd27d8da to your computer and use it in GitHub Desktop.
Ansible variable precedence from most to least important!

Ansible variable precedence

Source: http://docs.ansible.com/ansible/latest/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable

From most to least important

  1. set_facts / registered vars
  2. extra vars (always win precedence)
  3. include_vars
  4. include params
  5. role (and include_role) params
  6. task vars (only for the task)
  7. block vars (only for tasks in block)
  8. role vars (defined in role/vars/main.yml)
  9. play vars_files
  10. play vars_prompt
  11. play vars
  12. host facts
  13. playbook host_vars/*
  14. inventory host_vars/*
  15. inventory file or script host vars
  16. playbook group_vars/*
  17. inventory group_vars/*
  18. playbook group_vars/all
  19. inventory group_vars/all
  20. inventory file or script group vars
  21. role defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment