diff --git a/changelogs/fragments/29135-include_vars-check_for_main.yml b/changelogs/fragments/29135-include_vars-check_for_main.yml new file mode 100644 index 00000000000..f4d766ea3c1 --- /dev/null +++ b/changelogs/fragments/29135-include_vars-check_for_main.yml @@ -0,0 +1,2 @@ +bugfixes: +- Enhance the conditional check to include main.yml if it is not from 'role/vars/' (https://github.com/ansible/ansible/pull/51926). diff --git a/lib/ansible/plugins/action/include_vars.py b/lib/ansible/plugins/action/include_vars.py index 7c274f1fbda..425aa79dd14 100644 --- a/lib/ansible/plugins/action/include_vars.py +++ b/lib/ansible/plugins/action/include_vars.py @@ -1,19 +1,5 @@ -# (c) 2016, Allen Sanabria -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright: (c) 2016, Allen Sanabria +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type @@ -265,7 +251,7 @@ class ActionModule(ActionBase): stop_iter = False # Never include main.yml from a role, as that is the default included by the role if self._task._role: - if filename == 'main.yml': + if path.join(self._task._role._role_path, filename) == path.join(root_dir, 'vars', 'main.yml'): stop_iter = True continue