I used ansible's ec2_vol module to create an ebs volume. I saw the source code and found that it internally calls create_volume() method of boto with user specified parameters. I want to register the return value of ec2_vol module and get the volume_ids of newly created volumes.
As of now my playbook looks like
- name: Attach a volume to previously created instances
local_action: ec2_vol instance={{item.id}} volume_size=5 aws_access_key={{aa_key}} aws_secret_key={{as_key}} region={{region}}
with_items: ec2.instances
register: ec2_volumes
ignore_errors: yes
- name: Stop the instances
local_action: command aws ec2 stop-instances --profile=xervmon --instance-id={{item.id}}
with_items: ec2.instances
ignore_errors: yes
- name: Detach volume from instances
local_action: command aws ec2 detach-volume --profile=xervmon --volume-id=????
ignore_errors: yes
I would like to know how to get the volume ids of newly created volumes. I saw that run_instances() method's return object has an attribute instances whcih contain a list of instances. But I couldn't find any proper documentation of create_volume() method's return value.
Any help is appreciated.
Thanks,