我有一本字典,上面有字典列表。我该如何查找以检查键“ firstname”中是否存在某个名称?
---
- hosts: localhost
vars:
Persons:
- firstname: Bob
- firstname: Sarah
name: Sarah
tasks:
- debug: msg="{{ name in Persons }}" - ????
答案 0 :(得分:0)
在另一则帖子中找到了答案-
- debug: msg="{{ name in Persons | map(attribute='firstname') | list }}"