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
我的問題是,爲什麼在第二調試任務列表中([])的輸出?