遇到循环问题。尝试循环遍历aws查询的结果,以获取ALB的目标组的TargetHealth状态。看来我需要一个嵌套的循环结构,但无法弄明白。
任务:
- debug:
msg: "{{ item.stdout }}"
loop: "{{ arns.results }}"
输出
TASK [debug] *******************************************************************
ok: [localhost] => (item=None) =>
msg:
TargetHealthDescriptions:
- HealthCheckPort: '8091'
Target:
Id: i-00ceb9a71c24eaa5b
Port: 8091
TargetHealth:
State: healthy
ok: [localhost] => (item=None) =>
msg:
TargetHealthDescriptions:
- HealthCheckPort: '8090'
Target:
Id: i-00ceb9a71c24eaa5b
Port: 8090
TargetHealth:
State: healthy
我如何获得'州'?
答案 0 :(得分:0)
尝试 -
- debug:
msg: "{{ item }}"
when: '' != ( item | regex_search( 'State: ' ) )
with_items: "{{ arns.results.stdout_lines }}"
另一方面,我可能会在创建此输出的命令中尝试grep
...