Groups
Sign in
Groups
Ansible Project
Conversations
About
Send feedback
Help
Is there a cleaner way to use json_query to filter an array based on the value of an attribute?
15 views
Skip to first unread message
Behrang Saeedzadeh
unread,
Oct 17, 2017, 8:28:07 PM
10/17/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Hi,
The version of Ansible we are using does not support
selectattr
to filter a list based on attribute names. So I instead use something like this:
set_fact:
thing:
'{{ (things | json_query("[?thing_name==''" + a_thing_name + "'']") | list)[0] }}'
Is there a cleaner way to do this? Without using double single-quotes for escaping and + for concatenation?
Reply all
Reply to author
Forward
0 new messages