summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Tartaglia <andrea@braingap.uk>2019-05-08 13:11:00 +0100
committerWill Thames <will@thames.id.au>2019-05-08 22:10:58 +1000
commit5a6f8880360c3d4096b7e26ff9b00854f125337e (patch)
tree5fdb59ecf6dfe4f3eb5b3b5d96a21d1a31820d61
parent1462fd740b279ebe7dd791c8cac338a36ad413f6 (diff)
downloadansible-5a6f8880360c3d4096b7e26ff9b00854f125337e.tar.gz
ec2_instance: Force int when ebs.volume_size or ebs.iops is specified (#55716)
* Force int when volume_size is specified * changelog * both volume_size and iops must be int * updated changelog fragment
-rw-r--r--changelogs/fragments/55716-ec2_instance_int_volume_size.yml2
-rw-r--r--lib/ansible/modules/cloud/amazon/ec2_instance.py5
2 files changed, 7 insertions, 0 deletions
diff --git a/changelogs/fragments/55716-ec2_instance_int_volume_size.yml b/changelogs/fragments/55716-ec2_instance_int_volume_size.yml
new file mode 100644
index 0000000000..a78c064d9e
--- /dev/null
+++ b/changelogs/fragments/55716-ec2_instance_int_volume_size.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - ec2_instance - Ensures ``ebs.volume_size`` and ``ebs.iops`` are ``int`` to avoid issues with Jinja2 templating
diff --git a/lib/ansible/modules/cloud/amazon/ec2_instance.py b/lib/ansible/modules/cloud/amazon/ec2_instance.py
index c186cbbcce..c5822f24f4 100644
--- a/lib/ansible/modules/cloud/amazon/ec2_instance.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_instance.py
@@ -818,6 +818,11 @@ def manage_tags(match, new_tags, purge_tags, ec2):
def build_volume_spec(params):
volumes = params.get('volumes') or []
+ for volume in volumes:
+ if 'ebs' in volume:
+ for int_value in ['volume_size', 'iops']:
+ if int_value in volume['ebs']:
+ volume['ebs'][int_value] = int(volume['ebs'][int_value])
return [ec2_utils.snake_dict_to_camel_dict(v, capitalize_first=True) for v in volumes]