diff options
Diffstat (limited to 'lib/ansible/playbook/playbook_include.py')
-rw-r--r-- | lib/ansible/playbook/playbook_include.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/ansible/playbook/playbook_include.py b/lib/ansible/playbook/playbook_include.py index f1629b4f15..5e83f0d3a3 100644 --- a/lib/ansible/playbook/playbook_include.py +++ b/lib/ansible/playbook/playbook_include.py @@ -21,14 +21,16 @@ __metaclass__ = type import os +from ansible.errors import AnsibleParserError from ansible.parsing.splitter import split_args, parse_kv from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping from ansible.playbook.attribute import FieldAttribute from ansible.playbook.base import Base +from ansible.playbook.conditional import Conditional from ansible.playbook.taggable import Taggable -from ansible.errors import AnsibleParserError +from ansible.template import Templar -class PlaybookInclude(Base, Taggable): +class PlaybookInclude(Base, Conditional, Taggable): _name = FieldAttribute(isa='string') _include = FieldAttribute(isa='string') @@ -52,6 +54,14 @@ class PlaybookInclude(Base, Taggable): # playbook objects new_obj = super(PlaybookInclude, self).load_data(ds, variable_manager, loader) + all_vars = dict() + if variable_manager: + all_vars = variable_manager.get_vars(loader=loader) + + templar = Templar(loader=loader, variables=all_vars) + if not new_obj.evaluate_conditional(templar=templar, all_vars=all_vars): + return None + # then we use the object to load a Playbook pb = Playbook(loader=loader) |