好吧,这个问题困扰了两天,整整两天啊,我简直了
都是因为某个脚本返回的数据比较奇葩,格式如下[[“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]}}"
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021