Understand Ansible Variable


Understand how to use Ansible variable


pichuang - Ansible Variable Cheat Sheet

Last listed variables winning prioritization

In 2.x, we have made the order of precedence more specific (Low -> High Priority)

  1. role defaults
  2. inventory INI or script group vars
  3. inventory group_vars/all
  4. playbook group_vars/all
  5. inventory group_vars/*
  6. playbook group_vars/*
  7. inventory INI or script host vars
  8. inventory host_vars/*
  9. playbook host_vars/*
  10. host facts
  11. play vars
  12. play vars_prompt
  13. play vars_files
  14. role vars (defined in role/vars/main.yml)
  15. block vars (only for tasks in block)
  16. task vars (only for the task)
  17. role (and include_role) params
  18. include params
  19. include_vars
  20. set_facts / registered vars
  21. extra vars (always win precedence)