Load role vars and defaults before parsing tasks (#40982)

* Load role vars and defaults before parsing tasks. Fixes #40163

* Add porting guide note

* Wording clarifications

* typo

* grammar fixes
This commit is contained in:
Matt Martz 2018-06-18 10:56:55 -05:00 committed by GitHub
commit ee221859cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View file

@ -17,7 +17,14 @@ This document is part of a collection on porting. The complete list of porting g
Playbook
========
No notable changes.
Role Precedence Fix during Role Loading
---------------------------------------
Ansible 2.7 makes a small change to variable precedence when loading roles, resolving a bug, ensuring that role loading matches :ref:`variable precedence expectations <ansible_variable_precedence>`.
Before Ansible 2.7, when loading a role, the variables defined in the role's ``vars/main.yml`` and ``defaults/main.yml`` were not available when parsing the role's ``tasks/main.yml`` file. This prevented the role from utilizing these variables when being parsed. The problem manifested when ``import_tasks`` or ``import_role`` was used with a variable defined in the role's vars or defaults.
In Ansible 2.7, role ``vars`` and ``defaults`` are now parsed before ``tasks/main.yml``. This can cause a change in behavior if the same variable is defined at the play level and the role level with different values, and leveraged in ``import_tasks`` or ``import_role`` to define the role or file to import.
Deprecated
==========