diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2015-08-20 21:52:46 -0400 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2015-08-20 22:04:20 -0400 |
commit | fe06577ac284de31718c4723809b1d5e1cf5ca4f (patch) | |
tree | 43559092256d57553d40495423ce0a1c655cc7d0 /lib/ansible/plugins/test | |
parent | b5a078a3859764777aaf126c27284f65a5ea8dae (diff) | |
download | ansible-fe06577ac284de31718c4723809b1d5e1cf5ca4f.tar.gz |
fixed mandatory test
Diffstat (limited to 'lib/ansible/plugins/test')
-rw-r--r-- | lib/ansible/plugins/test/core.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/ansible/plugins/test/core.py b/lib/ansible/plugins/test/core.py index cc8c702d75..7de8e7436c 100644 --- a/lib/ansible/plugins/test/core.py +++ b/lib/ansible/plugins/test/core.py @@ -58,15 +58,6 @@ def skipped(*a, **kw): skipped = item.get('skipped', False) return skipped -def mandatory(a): - ''' Make a variable mandatory ''' - try: - a - except NameError: - raise errors.AnsibleFilterError('Mandatory variable not defined.') - else: - return a - def regex(value='', pattern='', ignorecase=False, match_type='search'): ''' Expose `re` as a boolean filter using the `search` method by default. This is likely only useful for `search` and `match` which already @@ -88,6 +79,14 @@ def search(value, pattern='', ignorecase=False): ''' Perform a `re.search` returning a boolean ''' return regex(value, pattern, ignorecase, 'search') +def mandatory(a): + from jinja2.runtime import Undefined + + ''' Make a variable mandatory ''' + if isinstance(a, Undefined): + raise errors.AnsibleFilterError('Mandatory variable not defined.') + return a + class TestModule(object): ''' Ansible core jinja2 tests ''' |