首页 » 翻译 » Ansible 入门 » 正文

ansible play book循环二维数组

好吧,这个问题困扰了两天,整整两天啊,我简直了

都是因为某个脚本返回的数据比较奇葩,格式如下[[“000000001″,”a”],[“000000002″,”a”],[“000000003″,”c”]]

然后我需要对这个字符串进行格式化处理,循环,结果死活取不到….

最后跑到freenode上的ansible去提问才知道的结果


---
- hosts: localhost
remote_user: root
gather_facts: no

vars:
myapps: [["000000001","a"],["000000002","a"],["000000003","c"]]

tasks:

- name: Output it
with_nested: "{{ [myapps] }}"
debug: msg="{{item[0]}} is {{item[1]}}"

Zhiming Zhang

Senior devops at Appannie
一个奔跑在运维路上的胖子
Zhiming Zhang

Latest posts by Zhiming Zhang (see all)