检查Ansible中是否存在元素

时间:2020-04-22 15:42:02

标签: ansible

我扮演Ansible角色:

rcube_plugins_repo:
    - name: 'account_details'
      repo: 'https://github.com/texxasrulez/account_details'
      config: 'yes'
    - name: 'delete_old'
      repo: 'https://github.com/ron4mac/roundcube_delete_old'
and so on...

在我的一项任务中,我需要检查account_details中是否存在rcube_plugins_repo

我该怎么做?

我想到了类似的东西:

when: "rcube_plugins_repo.name['account_details'] is defined"

但是它不起作用,我确定如何正确编写它。

非常感谢!

1 个答案:

答案 0 :(得分:1)

using System.Collections; using System.Collections.Generic; using UnityEngine; public class UpdateCursor : MonoBehaviour { HandleMouseCursor cursor; bool carrying; // Use this for initialization void Start () { cursor = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<HandleMouseCursor>(); } // Update is called once per frame void Update () { if (carrying) cursor.setGrab(); } private void OnMouseEnter() { cursor.setHand(); } private void OnMouseExit() { cursor.setMouse(); } private void OnMouseDown() { carrying = true; } private void OnMouseUp() { carrying = false; cursor.setMouse(); } } rcube_plugins_repo的列表,因此dict首先不会起作用。即使您有此价值,也必须将其与account_details进行比较,而不要检查rcube_plugins_repo.name子元素。

selectattr过滤器可让您根据过滤器过滤字典列表。在这里,您想过滤name属性的值。

我尝试了以下方法,它似乎可以工作:

account_details

如果过滤后的列表为空,则不符合条件。

相关问题