Revert "remove query/q (#36315)"

This reverts commit b47d2e07e1.

query is a feature for 2.5.  We're not reverting it now.
This commit is contained in:
Toshio Kuratomi 2018-02-21 08:25:56 -08:00
commit 03a6d72633
3 changed files with 56 additions and 2 deletions

View file

@ -299,7 +299,7 @@
- name: Test that we can give a list of values to var and receive a list of values back
set_fact:
var_host_info: '{{ lookup("vars", "ansible_host", "ansible_user", wantlist=True) }}'
var_host_info: '{{ query("vars", "ansible_host", "ansible_user") }}'
- assert:
that:

View file

@ -103,6 +103,54 @@
- 'results6["results"][0]["ping"] == "Hello World"'
- '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
#