Я новичок в Ansible, и это моя первая попытка.У меня есть задача получить атрибут Address
из конечной точки консула nodes
.Моя игра выглядит следующим образом
- hosts: localhost
connection: local
tasks:
- name: "Get the addresses"
block:
- name: 'Fetching addresses from consul.'
uri:
url: http://consul-server/v1/catalog/nodes
status_code: 200
body_format: json
return_content: yes
register: nodes
- set_fact:
frontend_ips: "{{ item.Address }}"
when: item.Node == "*hero_node*"
loop: "{{ nodes }}"
здесь я пытаюсь получить все узлы у консула, а затем отфильтровать Addresses
узла, содержащего hero_node
в названии узла, но я получаюисключение:
fatal: [localhost]: FAILIED! => {}.
MSG: Unexpected failure in finding the lookup name '{{ nodes }} in the available lookup plugin'
nodes json
возврат из конечной точки выглядит следующим образом:
[
{
"Address": "111.111.11.1",
"Node": "hero-node-1",
"Metadata": ...
...
},
{
...
...
}
]
Любая помощь будет очень признательна.