remove query/q (#36315)
* remove query/q remove and fixed tests for removed func * paren fix
This commit is contained in:
parent
5d0ed38e3a
commit
b47d2e07e1
3 changed files with 2 additions and 56 deletions
|
@ -604,11 +604,6 @@ class Templar:
|
||||||
def _fail_lookup(self, name, *args, **kwargs):
|
def _fail_lookup(self, name, *args, **kwargs):
|
||||||
raise AnsibleError("The lookup `%s` was found, however lookups were disabled from templating" % name)
|
raise AnsibleError("The lookup `%s` was found, however lookups were disabled from templating" % name)
|
||||||
|
|
||||||
def _query_lookup(self, name, *args, **kwargs):
|
|
||||||
''' wrapper for lookup, force wantlist true'''
|
|
||||||
kwargs['wantlist'] = True
|
|
||||||
return self._lookup(name, *args, **kwargs)
|
|
||||||
|
|
||||||
def _lookup(self, name, *args, **kwargs):
|
def _lookup(self, name, *args, **kwargs):
|
||||||
instance = self._lookup_loader.get(name.lower(), loader=self._loader, templar=self)
|
instance = self._lookup_loader.get(name.lower(), loader=self._loader, templar=self)
|
||||||
|
|
||||||
|
@ -699,10 +694,9 @@ class Templar:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
if disable_lookups:
|
if disable_lookups:
|
||||||
t.globals['query'] = t.globals['q'] = t.globals['lookup'] = self._fail_lookup
|
t.globals['lookup'] = self._fail_lookup
|
||||||
else:
|
else:
|
||||||
t.globals['lookup'] = self._lookup
|
t.globals['lookup'] = self._lookup
|
||||||
t.globals['query'] = t.globals['q'] = self._query_lookup
|
|
||||||
|
|
||||||
t.globals['finalize'] = self._finalize
|
t.globals['finalize'] = self._finalize
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@
|
||||||
|
|
||||||
- name: Test that we can give a list of values to var and receive a list of values back
|
- name: Test that we can give a list of values to var and receive a list of values back
|
||||||
set_fact:
|
set_fact:
|
||||||
var_host_info: '{{ query("vars", "ansible_host", "ansible_user") }}'
|
var_host_info: '{{ lookup("vars", "ansible_host", "ansible_user", wantlist=True) }}'
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|
|
@ -103,54 +103,6 @@
|
||||||
- 'results6["results"][0]["ping"] == "Hello World"'
|
- 'results6["results"][0]["ping"] == "Hello World"'
|
||||||
- 'results6["results"][1]["ping"] == "Olá Mundo"'
|
- 'results6["results"][1]["ping"] == "Olá Mundo"'
|
||||||
|
|
||||||
- name: Test that loop works with a list via the query lookup
|
|
||||||
ping:
|
|
||||||
data: '{{ item }}'
|
|
||||||
loop: '{{ query("list", "Hello World", "Olá Mundo") }}'
|
|
||||||
register: results7
|
|
||||||
|
|
||||||
- name: Assert that we ran the module twice with the correct strings
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- 'results7["results"][0]["ping"] == "Hello World"'
|
|
||||||
- 'results7["results"][1]["ping"] == "Olá Mundo"'
|
|
||||||
|
|
||||||
- name: Test that loop works with a list in a variable via the query lookup
|
|
||||||
ping:
|
|
||||||
data: '{{ item }}'
|
|
||||||
loop: '{{ q("list", *phrases) }}'
|
|
||||||
register: results8
|
|
||||||
|
|
||||||
- name: Assert that we ran the module twice with the correct strings
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- 'results8["results"][0]["ping"] == "Hello World"'
|
|
||||||
- 'results8["results"][1]["ping"] == "Olá Mundo"'
|
|
||||||
|
|
||||||
- name: Test that loop works with a list and keyword args
|
|
||||||
ping:
|
|
||||||
data: '{{ item }}'
|
|
||||||
loop: '{{ q("file", "data1.txt", "data2.txt", lstrip=True) }}'
|
|
||||||
register: results9
|
|
||||||
|
|
||||||
- name: Assert that we ran the module twice with the correct strings
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- 'results9["results"][0]["ping"] == "Hello World"'
|
|
||||||
- 'results9["results"][1]["ping"] == "Olá Mundo"'
|
|
||||||
|
|
||||||
- name: Test that loop works with a list in variable and keyword args
|
|
||||||
ping:
|
|
||||||
data: '{{ item }}'
|
|
||||||
loop: '{{ q("file", lstrip=True, *filenames) }}'
|
|
||||||
register: results10
|
|
||||||
|
|
||||||
- name: Assert that we ran the module twice with the correct strings
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- 'results10["results"][0]["ping"] == "Hello World"'
|
|
||||||
- 'results10["results"][1]["ping"] == "Olá Mundo"'
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# loop_control/index_var
|
# loop_control/index_var
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue