Fix ec2_snapshot_facts traceback if a snapshot has been deleted (#32217)
This commit is contained in:
parent
53ade280a3
commit
cabd7f078b
1 changed files with 6 additions and 1 deletions
|
@ -193,7 +193,12 @@ def list_ec2_snapshots(connection, module):
|
||||||
try:
|
try:
|
||||||
snapshots = connection.describe_snapshots(SnapshotIds=snapshot_ids, OwnerIds=owner_ids, RestorableByUserIds=restorable_by_user_ids, Filters=filters)
|
snapshots = connection.describe_snapshots(SnapshotIds=snapshot_ids, OwnerIds=owner_ids, RestorableByUserIds=restorable_by_user_ids, Filters=filters)
|
||||||
except ClientError as e:
|
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
|
# Turn the boto3 result in to ansible_friendly_snaked_names
|
||||||
snaked_snapshots = []
|
snaked_snapshots = []
|
||||||
|
|
Loading…
Reference in a new issue