不是这样的with_subelements
是的。如果使用此“DEBUG”循环打印{Item},将看到在每次迭代中,它将创建以下列表:
couchbase
列表,该列表保存指定的子元素,而不包含该子元素的散列和这是输出:
TASK [debug] ********************************************************************************************************************************************************************************************************
ok: [localhost] => (item=None) => {
"msg": [
{
"ipaddress": [
"10.16.9.177",
"10.16.9.178"
],
"name": "incre1"
},
"AA1"
]
}
ok: [localhost] => (item=None) => {
"msg": [
{
"ipaddress": [
"10.16.9.177",
"10.16.9.178"
],
"name": "incre1"
},
"aa1"
]
}
PLAY RECAP
正如澄清的,意图是在ipaddress
和buckets
。
要实现这一点,请尝试以下任务:
- debug:
msg: "Running backup as {{CBBACKUPMGR}} backup -r {{ item[0] }} --cluster couchbase://{{ item[1] }}"
register: example
with_items:
- "{{ lookup('nested', couchbase[0].ipaddress, couchbase[0].buckets) }}"
这假设将拥有couchbase
列表变量只有一个元素,就像在示例中一样。
结果:
TASK [debug] ********************************************************************************************************************************************************************************************************
ok: [localhost] => (item=None) => {
"msg": "Running backup as /opt/ouchbase backup -r 10.16.9.177 --cluster couchbase://AA1"
}
ok: [localhost] => (item=None) => {
"msg": "Running backup as /opt/ouchbase backup -r 10.16.9.177 --cluster couchbase://aa1"
}
ok: [localhost] => (item=None) => {
"msg": "Running backup as /opt/ouchbase backup -r 10.16.9.178 --cluster couchbase://AA1"
}
ok: [localhost] => (item=None) => {
"msg": "Running backup as /opt/ouchbase backup -r 10.16.9.178 --cluster couchbase://aa1"
}
PLAY RECAP