ec2_vol create dynamic number

41 views
Skip to first unread message

Mark Olliver

unread,
Feb 18, 2015, 12:07:21 PM2/18/15
to ansible...@googlegroups.com
Hi,

How can I extend the following code to allow me to specify a number of additional volumes to add?

- name: create ec2 vols for raid
  local_action: ec2_vol
    instance="{{ item[0].id }}"
    volume_size="{{ md_vol_size }}"
    device_name="{{ item[1] }}"
    region="{{ item[0].region }}"
  with_nested:
    - ec2_info.instances
    - ['xvdg', 'xvdh', 'xvdi', 'xvdj']


I.e sometimes i might want just one additional volume but others i might want to attach 10 xvdg-p ideally based of a variable called ec2_vol_count=X

Thanks

Mark

Dan Vaida

unread,
Feb 20, 2015, 5:11:06 AM2/20/15
to ansible...@googlegroups.com, ma...@olliver.me.uk
Although not the nicest way to do it, I recon the with_sequence could come in handy: http://docs.ansible.com/playbooks_loops.html#looping-over-integer-sequences
Reply all
Reply to author
Forward
0 new messages