检查字典列表中是否存在值

时间:2020-09-11 08:21:02

标签: ansible

我有一本字典,上面有字典列表。我该如何查找以检查键“ firstname”中是否存在某个名称?

---
 - hosts: localhost
  
   vars:
     Persons:
       - firstname: Bob
       - firstname: Sarah

     name: Sarah

   tasks:
    - debug: msg="{{ name in Persons }}" - ????

1 个答案:

答案 0 :(得分:0)

在另一则帖子中找到了答案-

- debug: msg="{{ name in Persons | map(attribute='firstname') | list }}"
相关问题