Skip to content

Commit

Permalink
ec2_vol: preset the name tag of the volume
Browse files Browse the repository at this point in the history
  • Loading branch information
goneri committed Jan 18, 2021
1 parent 05c557e commit 559c5cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- ec2_vol - create or update now preserves the existing tags, including Name (https://github.com/ansible-collections/amazon.aws/issues/229)
3 changes: 2 additions & 1 deletion plugins/modules/ec2_vol.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,8 @@ def main():
else:
volume, changed = create_volume(module, ec2_conn, zone=zone)

tags['Name'] = name
if name:
tags['Name'] = name
final_tags, tags_changed = ensure_tags(module, ec2_conn, volume['volume_id'], 'volume', tags, False)

if detach_vol_flag:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/ec2_vol/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
- "'attachment_set' in volume1.volume"
- "'instance_id' in volume1.volume.attachment_set"
- not volume1.volume.attachment_set.instance_id
- not ("Name" in volume1.volume.tags)
- not volume1.volume.encrypted

# no idempotency check needed here
Expand Down Expand Up @@ -102,6 +103,7 @@
- volume2.volume_type == 'io1'
- volume2.volume.iops == 101
- volume2.volume.size == 4
- volume2.volume.tags.Name == "{{ resource_prefix }}"
- volume2.volume.encrypted

- name: create another volume (override module defaults) (idempotent)
Expand Down

0 comments on commit 559c5cd

Please sign in to comment.