Я хочу получить список адресов определенного типа интерфейса.
Я нашел кое-какую информацию здесь.
Вот моя инструкция:
- name: Test JMESPath
hosts: localhost
gather_facts: no
vars:
interfaces:
- name: em0
address: 10.127.37.89/29
- name: bge0
address: 10.112.171.81/28
- name: bge1
address: 10.112.171.65/28
- name: bge2
address: 10.112.171.97/28
tasks:
- name: JMESPath query
set_fact:
result: "{{ interfaces | json_query(query) }}"
vars:
query: "[?name.contains(@, 'bge')].address"
- debug:
var: result
Я бы хотел получить:
[
"10.112.171.81/28",
"10.112.171.65/28",
"10.112.171.97/28"
]
Он работает на веб-сайте JMESPath, но моя книга не работает:
ansible-playbook play-testJMESPath.yml [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' PLAY [Test JMESPath] ************************************************************************************************************************************************************************************************** TASK [JMESPath query] ************************************************************************************************************************************************************************************************* fatal: [localhost]: FAILED! => {"msg": "JMESPathError in json_query filter plugin:\nIn function contains(), invalid type for value: external, expected one of: ['array', 'string'], received: \"unknown\""} PLAY RECAP ************************************************************************************************************************************************************************************************************ localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Может кто-нибудь объяснить мне, почему?