1
我在OSX上运行asible 2.4.0。 下面的剧本......当使用过滤器表达式时,Ansible json_query输出列表
---
- hosts: localhost
connection: local
gather_facts: False
vars:
data:
- name: thing1
desc: I am thing 1
- name: thing2
desc: I am thing 2
tasks:
- debug: msg="{{ data|json_query(\"[1].desc\") }}"
- debug: msg="{{ data|json_query(\"[?name=='thing2'].desc\") }}"
产生以下输出:
PLAY [localhost] ***************************************************************
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "I am thing 2"
}
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": [
"I am thing 2"
]
}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
我的问题是,为什么在第二调试任务列表中([])的输出?