Python Ansible无法从目录列表中获取值

Python Ansible无法从目录列表中获取值,python,xml,ansible,ansible-playbook,Python,Xml,Ansible,Ansible Playbook,我需要: -使用“位置”的调试值回显 -检查“位置”是否包含特定单词(整个单词都可以) 根据以下程序生成的输出: 在任务中注册变量,然后使用when子句创建新任务 - Existing XML task xml: (skipping) register: myvar - Check for filename debug: var=item.application.location with_items: myvar.apps.matches 编辑:从注

我需要: -使用“位置”的调试值回显 -检查“位置”是否包含特定单词(整个单词都可以)

根据以下程序生成的输出:


在任务中注册变量,然后使用when子句创建新任务

  - Existing XML task
    xml: (skipping)
    register: myvar

  - Check for filename
    debug: var=item.application.location
    with_items: myvar.apps.matches

编辑:从注释中,由于匹配是一个数组,您可能希望遍历该数组。

您是否尝试过某种方法,或者您只是假设ansible无法从dicts列表中获取值?@shapsI已经尝试过,使用apps.matches可以正常工作,但无法进入应用程序。app.matches[“application”]不起作用不,这不起作用,正如您在标题中所说,这是一个dict列表,因此您必须以
app.matches[0]['application']
- debug:
    var: item.application
  when: item.application.location == "foobar"
  with_items: "{{ apps.matches }}"
- debug:
    var: item.application
  when: item.application.location == "foobar"
  with_items: "{{ apps.matches }}"