mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Add generic data structures querying (#13684)
* Query lookup plugin * Add license and docstrings * Add python3-ish imports * Change query plugin type from lookup to filter * Switch from dq to jsonpath_rw * Add integration test for query filter * Rename query filter to json_query * Add jsonpath-rw * Rename query filter to json_query * Switch query implementation from jsonpath-rw to jmespath
This commit is contained in:
committed by
Brian Coca
parent
f21df311bc
commit
e54a9d3a51
@@ -40,8 +40,8 @@
|
||||
register: diff_result_9851
|
||||
|
||||
- name: 9851 - verify generated file matches known good
|
||||
assert:
|
||||
that:
|
||||
assert:
|
||||
that:
|
||||
- 'diff_result_9851.stdout == ""'
|
||||
|
||||
- name: fill in a basic template
|
||||
@@ -56,9 +56,9 @@
|
||||
register: diff_result
|
||||
|
||||
- name: verify templated file matches known good
|
||||
assert:
|
||||
that:
|
||||
- 'diff_result.stdout == ""'
|
||||
assert:
|
||||
that:
|
||||
- 'diff_result.stdout == ""'
|
||||
|
||||
- name: Verify human_readable
|
||||
assert:
|
||||
@@ -77,3 +77,9 @@
|
||||
- "31 == ['x','y']|map('extract',{'x':42,'y':31})|list|last"
|
||||
- "'local' == ['localhost']|map('extract',hostvars,'ansible_connection')|list|first"
|
||||
- "'local' == ['localhost']|map('extract',hostvars,['ansible_connection'])|list|first"
|
||||
|
||||
- name: Test json_query filter
|
||||
assert:
|
||||
that:
|
||||
- "users | json_query('[*].hosts[].host') == ['host_a', 'host_b', 'host_c', 'host_d']"
|
||||
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
some_structure:
|
||||
- "this is a list element"
|
||||
-
|
||||
-
|
||||
this: "is a hash element in a list"
|
||||
warp: 9
|
||||
where: endor
|
||||
|
||||
users:
|
||||
- name: steve
|
||||
hosts:
|
||||
- host: host_a
|
||||
password: abc
|
||||
- host: host_b
|
||||
- name: bill
|
||||
hosts:
|
||||
- host: host_c
|
||||
password: default
|
||||
- host: host_d
|
||||
|
||||
Reference in New Issue
Block a user