- playbook
test.yml
---
- hosts: localhost
gather_facts: no
connection: local
vars:
type: st1
size: 2000
instance_ids:
- xxx
- yyy
- zzz
objs:
- { key1: /dev/sdb1, key2: "{{instance_ids}}" }
- { key1: /dev/sdc1, key2: "{{instance_ids}}" }
- { key1: /dev/sdd1, key2: "{{instance_ids}}" }
tasks:
- name: 2nd --------
debug: msg="{{ item.0.key1 }} and {{ item.1 }} and {{ size }} and {{ type }}"
with_subelements:
- "{{ objs }}"
- key2
-
usage:
ansible-playbook test.yml -i hosts/all | grep -i "msg"
-
output:
"msg": "/dev/sdb1 and xxx and 2000 and st1"
"msg": "/dev/sdb1 and yyy and 2000 and st1"
"msg": "/dev/sdb1 and zzz and 2000 and st1"
"msg": "/dev/sdc1 and xxx and 2000 and st1"
"msg": "/dev/sdc1 and yyy and 2000 and st1"
"msg": "/dev/sdc1 and zzz and 2000 and st1"
"msg": "/dev/sdd1 and xxx and 2000 and st1"
"msg": "/dev/sdd1 and yyy and 2000 and st1"
"msg": "/dev/sdd1 and zzz and 2000 and st1"