ec2_vol create multiple devices

Hi

i have trying to create several ec2 instances and 4 volumes for each instance, and i had trouble with it, here is part of it:

create several instances :

  • name: Launch instances
    local_action:
    module: ec2
    image: “{{ image }}”
    instance_type: “{{ instance_type }}”
    keypair: “{{ keypair }}”
    instance_tags: ‘{ “Name”:“{{ hostname }}” , “Group”:“nginx_backend” }’
    region: “{{ region }}”
    group: “{{ group }}”
    zone: “{{ zone }}”
    wait: “true”
    spot_wait_timeout: 300

count: “{{count}}”
register: ec2

and now upon that create for each instance several volumes

  • name: Create Volume
    local_action:
    module: ec2_vol
    instance: “{{ item.id }}”
    device_name: “/dev/xvd{{ item.1 }}”

region: “{{ region }}”
zone: “{{ zone }}”
volume_size: “{{volume_size}}”
volume_type: “gp2”
with_items: ec2.instances
register: ec2_vol

so i have tried to add with_together …

with_together:

  • [ ‘d’, ‘e’, ‘f’ , ‘g’ ]

and seems that with_items and with_together are not working together , i have tried with_nested and other issue as loop, nothing work.

who can help me here?

i will be very appreciated…:slight_smile:

Igal