아마도 그는 다음과 같이 더욱 역동적 인 것이 필요할 것입니다.
이것은 2.1에서 가능합니다. 해시 키의 배열을 갖는 해시의 하위 집합을 가져와야했지만,이 게시물에 대해 비틀 거리며 솔루션을 발견했습니다.
나는 that을 사용합니다.
나는 완전히 어리 석고 쓸모 없지만 완전한 예를 제공하기로 선택한다.
---
- hosts: localhost
vars:
filenames: [ file1, file2 ]
file1:
a: file1.c
b: file1.o
file2:
a: file2.c
b: file2.o
file3:
a: file3.py
b: file3.pyc
tasks:
- debug: msg="gcc -c -o {{item.b}} {{item.a}}"
with_items:
- "{{ filenames | map('extract', vars) | list}}"
ansible - 각본의 출력은 이것이다 :
PLAY [localhost] ***************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => (item={u'a': u'file1.c', u'b': u'file1.o'}) => {
"item": {
"a": "file1.c",
"b": "file1.o"
},
"msg": "gcc -c -o file1.o file1.c"
}
ok: [localhost] => (item={u'a': u'file2.c', u'b': u'file2.o'}) => {
"item": {
"a": "file2.c",
"b": "file2.o"
},
"msg": "gcc -c -o file2.o file2.c"
}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
나는이 의견에 관심이 있어요.