mirror of https://github.com/ansible/ansible.git
avoid roles exporting vars: (#69040)
- correct 'vars:' precedence to allow phasing out of include_params - actually merge vars and always include role_vars - avoided dupe deps from giving wrong vars - use 'first' instance of dep as others are from previous instances/invocations and can have diff values for vars - ensured deps only provide exportable vars themselves - added COMMENTS - added tests - apply export restrictions setting to defaults - use 'public' as cutoff Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> ci_completepull/78916/head
parent
3423a6609f
commit
0b678d5036
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- Fix bug in `vars` applied to roles, they were being incorrectly exported among others while only vars/main.yml was meant to be. Also adjusted the precedence to act the same as inline params.
|
@ -0,0 +1,10 @@
|
||||
default_only: default
|
||||
role_vars_only: default
|
||||
play_and_role_vars: default
|
||||
play_and_roles_and_role_vars: default
|
||||
play_and_import_and_role_vars: default
|
||||
play_and_include_and_role_vars: default
|
||||
play_and_role_vars_and_role_vars: default
|
||||
roles_and_role_vars: default
|
||||
import_and_role_vars: default
|
||||
include_and_role_vars: default
|
@ -0,0 +1 @@
|
||||
../../../tasks/check_vars.yml
|
@ -0,0 +1 @@
|
||||
- include_tasks: check_vars.yml
|
@ -0,0 +1,9 @@
|
||||
role_vars_only: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
roles_and_role_vars: role_vars
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
@ -0,0 +1,7 @@
|
||||
- debug: var={{item}}
|
||||
loop: '{{possible_vars}}'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- (item in vars and item in defined and vars[item] == defined[item]) or (item not in vars and item not in defined)
|
||||
loop: '{{possible_vars}}'
|
@ -0,0 +1,26 @@
|
||||
play_only: play
|
||||
play_and_roles: play
|
||||
play_and_import: play
|
||||
play_and_include: play
|
||||
play_and_role_vars: play
|
||||
play_and_roles_and_role_vars: play
|
||||
play_and_import_and_role_vars: play
|
||||
play_and_include_and_role_vars: play
|
||||
possible_vars:
|
||||
- default_only
|
||||
- import_and_role_vars
|
||||
- import_only
|
||||
- include_and_role_vars
|
||||
- include_only
|
||||
- play_and_import
|
||||
- play_and_import_and_role_vars
|
||||
- play_and_include
|
||||
- play_and_include_and_role_vars
|
||||
- play_and_roles
|
||||
- play_and_roles_and_role_vars
|
||||
- play_and_role_vars
|
||||
- play_and_role_vars_and_role_vars
|
||||
- play_only
|
||||
- roles_and_role_vars
|
||||
- roles_only
|
||||
- role_vars_only
|
@ -0,0 +1,335 @@
|
||||
- name: play and roles
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- vars/play.yml
|
||||
roles:
|
||||
- name: vars_scope
|
||||
vars:
|
||||
roles_only: roles
|
||||
roles_and_role_vars: roles
|
||||
play_and_roles: roles
|
||||
play_and_roles_and_role_vars: roles
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: roles
|
||||
play_and_roles_and_role_vars: roles
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: roles
|
||||
roles_only: roles
|
||||
role_vars_only: role_vars
|
||||
|
||||
pre_tasks:
|
||||
- include_tasks: tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
tasks:
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- name: play and import
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- vars/play.yml
|
||||
tasks:
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: play
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: play
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: play
|
||||
play_and_role_vars: play
|
||||
play_only: play
|
||||
|
||||
- name: static import
|
||||
import_role:
|
||||
name: vars_scope
|
||||
vars:
|
||||
import_only: import
|
||||
import_and_role_vars: import
|
||||
play_and_import: import
|
||||
play_and_import_and_role_vars: import
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: import
|
||||
import_only: import
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: import
|
||||
play_and_import_and_role_vars: import
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- name: play and include
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- vars/play.yml
|
||||
tasks:
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: play
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: play
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: play
|
||||
play_and_role_vars: play
|
||||
play_only: play
|
||||
|
||||
- name: dynamic include
|
||||
include_role:
|
||||
name: vars_scope
|
||||
vars:
|
||||
include_only: include
|
||||
include_and_role_vars: include
|
||||
play_and_include: include
|
||||
play_and_include_and_role_vars: include
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: include
|
||||
include_only: include
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: include
|
||||
play_and_include_and_role_vars: include
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: play
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: play
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: play
|
||||
play_and_role_vars: play
|
||||
play_only: play
|
||||
|
||||
- name: play and roles and import and include
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
vars_files:
|
||||
- vars/play.yml
|
||||
roles:
|
||||
- name: vars_scope
|
||||
vars:
|
||||
roles_only: roles
|
||||
roles_and_role_vars: roles
|
||||
play_and_roles: roles
|
||||
play_and_roles_and_role_vars: roles
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: roles
|
||||
play_and_roles_and_role_vars: roles
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: roles
|
||||
roles_only: roles
|
||||
role_vars_only: role_vars
|
||||
|
||||
pre_tasks:
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
tasks:
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- name: static import
|
||||
import_role:
|
||||
name: vars_scope
|
||||
vars:
|
||||
import_only: import
|
||||
import_and_role_vars: import
|
||||
play_and_import: import
|
||||
play_and_import_and_role_vars: import
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: import
|
||||
import_only: import
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: import
|
||||
play_and_import_and_role_vars: import
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- name: dynamic include
|
||||
include_role:
|
||||
name: vars_scope
|
||||
vars:
|
||||
include_only: include
|
||||
include_and_role_vars: include
|
||||
play_and_include: include
|
||||
play_and_include_and_role_vars: include
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: include
|
||||
include_only: include
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: include
|
||||
play_and_include_and_role_vars: include
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
||||
|
||||
- include_tasks: roles/vars_scope/tasks/check_vars.yml
|
||||
vars:
|
||||
defined:
|
||||
default_only: default
|
||||
import_and_role_vars: role_vars
|
||||
include_and_role_vars: role_vars
|
||||
play_and_import: play
|
||||
play_and_import_and_role_vars: role_vars
|
||||
play_and_include: play
|
||||
play_and_include_and_role_vars: role_vars
|
||||
play_and_roles: play
|
||||
play_and_roles_and_role_vars: role_vars
|
||||
play_and_role_vars: role_vars
|
||||
play_and_role_vars_and_role_vars: role_vars
|
||||
play_only: play
|
||||
roles_and_role_vars: role_vars
|
||||
role_vars_only: role_vars
|
Loading…
Reference in New Issue