Hi,
is there any possibility to get the id of the root EBS volume of a newly created EC2 instance? I cannot find any documentation about it?
Thanks,
Christian
Hi,
is there any possibility to get the id of the root EBS volume of a newly created EC2 instance? I cannot find any documentation about it?
Thanks,
Christian
Hi Christian,
How would you like to obtain the information - at instance creation time or at an arbitrary point in time later? (i.e. do you want to be able to get the instance ID as a value returned by the ec2 module, or from ec2_facts?)
Will
Had a quick look at this in more detail.
Neither the ec2 nor the ec2_facts module expose this information. It is available but in particular adding it to ec2_facts module would require fundamental changes (as currently the ec2_facts module gets all of its information from logging onto the box and reading the metadata, whereas this information would only be available through talking to the API - see http://stackoverflow.com/questions/5251057/using-boto-to-find-to-which-device-and-ebs-volume-is-mounted). I’m not adverse to such a change but making it optional and non-breaking for other users of the module is probably the challenge.
Returning the value from the ec2 module is probably quite straightforward, on the other hand.
Will
Hi Will,
Thanks for your answer.
I would like to create a tag for the root volume. So for my use case the ec2 module should return the IDs and the device names of the attached volumes after instance creation.
Should I create a future request and point to this thread?
Thanks,
Christian
I was just looking into how I might implement this and there’s an interesting side effect of ec2_vol if a volume is already attached
Assuming you run ec2 and register the result as ec2, the following works:
(note that volume_size doesn’t matter, it’s ignored but the module fails without it - with an error message that can only be described as unhelpful!)
You get as a result:
ok: [127.0.0.1] => {“changed”: false, “device”: “/dev/sda1”, “msg”: “Volume mapping for /dev/sda1 already exists on instance i-834ab5bd”, “volume_id”: “vol-92cee996”}
And so you can use ec2_vol.volume_id as a resource id to pass to ec2_tag.
Will
Hi Will,
works like a charm.
Many thanks.
Christian