1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix ec2_snapshot_facts traceback if a snapshot has been deleted (#32217)

This commit is contained in:
Sloane Hertel 2017-11-15 10:56:49 -05:00 committed by Ryan Brown
parent 53ade280a3
commit cabd7f078b

View file

@ -193,7 +193,12 @@ def list_ec2_snapshots(connection, module):
try:
snapshots = connection.describe_snapshots(SnapshotIds=snapshot_ids, OwnerIds=owner_ids, RestorableByUserIds=restorable_by_user_ids, Filters=filters)
except ClientError as e:
module.fail_json(msg=e.message)
if e.response['Error']['Code'] == "InvalidSnapshot.NotFound":
if len(snapshot_ids) > 1:
module.warn("Some of your snapshots may exist, but %s" % str(e))
snapshots = {'Snapshots': []}
else:
module.fail_json(msg="Failed to describe snapshots: %s" % str(e))
# Turn the boto3 result in to ansible_friendly_snaked_names
snaked_snapshots = []