From 96cbd61d5e7b5759dbe58505334ae6bbdab0afba Mon Sep 17 00:00:00 2001 From: Blair Zajac Date: Sun, 17 Mar 2013 15:30:16 -0700 Subject: [PATCH 1/2] ec2_vol: update docs to match default device_name values for Unix/Windows. --- library/ec2_vol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ec2_vol b/library/ec2_vol index e6f29e6ba01..8e6da4eb042 100644 --- a/library/ec2_vol +++ b/library/ec2_vol @@ -36,7 +36,7 @@ options: aliases: [] device_name: description: - - device id to override device mapping. Assumes /dev/sdf for instance-store, /dev/sdb for EBS. + - device id to override device mapping. Assumes /dev/sdf for Linux/UNIX and /dev/xvdf for Windows. required: false default: null aliases: [] From 1aa2f9749ec8954a709cd2094b54aabc5d6c9189 Mon Sep 17 00:00:00 2001 From: Blair Zajac Date: Sun, 17 Mar 2013 15:46:33 -0700 Subject: [PATCH 2/2] ec2_vol: do no work if the instance has a volume mounted at the device. --- library/ec2_vol | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/ec2_vol b/library/ec2_vol index 8e6da4eb042..f2d41657364 100644 --- a/library/ec2_vol +++ b/library/ec2_vol @@ -19,7 +19,7 @@ DOCUMENTATION = ''' module: ec2_vol short_description: create and attach a volume, return volume id and device map description: - - creates an EBS volume and optionally attaches it to an instance. This module has a dependency on python-boto + - creates an EBS volume and optionally attaches it to an instance. If both an instance ID and a device name is given and the instance has a device at the device name, then no volume is created and no attachment is made. This module has a dependency on python-boto. version_added: "1.1" options: instance: @@ -123,6 +123,12 @@ def main(): inst = reservation[0].instances[0] zone = inst.placement + # Check if there is a volume already mounted there. + if device_name: + if device_name in inst.block_device_mapping: + module.exit_json(msg="Volume mapping for %s already exists on instance %s" % (device_name, instance), + changed=False) + # If no instance supplied, try volume creation based on module parameters. try: