From cf2a66ef3083fa3f6f2deac1b75e7fc3f07682df Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 10 Jul 2015 03:22:37 -0400 Subject: [PATCH] Add ansible_version magic variable Fixes #11545 --- lib/ansible/vars/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/vars/__init__.py b/lib/ansible/vars/__init__.py index 40589b9db05..591066e0785 100644 --- a/lib/ansible/vars/__init__.py +++ b/lib/ansible/vars/__init__.py @@ -30,6 +30,7 @@ except ImportError: from sha import sha as sha1 from ansible import constants as C +from ansible.cli import CLI from ansible.errors import * from ansible.parsing import DataLoader from ansible.plugins.cache import FactCache @@ -244,6 +245,8 @@ class VariableManager: # the 'omit' value alows params to be left out if the variable they are based on is undefined all_vars['omit'] = self._omit_token + all_vars['ansible_version'] = CLI.version_info(gitinfo=False) + # make vars self referential, so people can do things like 'vars[var_name]' copied_vars = all_vars.copy() if 'hostvars' in copied_vars: