From 1637aeea297f54b60c418e910d69a59c19ae4297 Mon Sep 17 00:00:00 2001 From: Simon Dodsley Date: Thu, 6 Jun 2019 00:07:39 +0200 Subject: [PATCH] Make purefa_pgsnap module handle its own exit correctly (#56954) --- lib/ansible/modules/storage/purestorage/purefa_pgsnap.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/storage/purestorage/purefa_pgsnap.py b/lib/ansible/modules/storage/purestorage/purefa_pgsnap.py index 20420ef242..34f4a83d2a 100644 --- a/lib/ansible/modules/storage/purestorage/purefa_pgsnap.py +++ b/lib/ansible/modules/storage/purestorage/purefa_pgsnap.py @@ -235,8 +235,12 @@ def main(): module.fail_json(msg="Selected volume {0} does not exist in the Protection Group".format(module.params['name'])) if ":" in module.params['name']: rvolume = get_rpgsnapshot(module, array) + if rvolume is None: + module.fail_json(msg="Selected restore snapshot {0} does not exist in the Protection Group".format(module.params['restore'])) else: rvolume = get_pgroupvolume(module, array) + if rvolume is None: + module.fail_json(msg="Selected restore volume {0} does not exist in the Protection Group".format(module.params['restore'])) if state == 'copy' and rvolume: restore_pgsnapvolume(module, array) @@ -251,6 +255,8 @@ def main(): elif state == 'absent' and not pgsnap: module.exit_json(changed=False) + module.exit_json(changed=False) + if __name__ == '__main__': main()