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

[icinga2_host.py] Actually return codes instead of data (#335) (#1431)

* [icinga2_host.py] Actually return codes instead of data

Currently the module tries to return the `data`, which can result in a blank message instead of the code being shown.

```
 "msg": "bad return code creating host: "
```

* add changelog fragment

* Update changelogs/fragments/335-icinga2_host-return-error-code.yaml

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

* return code and data on fail

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: John R Barker <john@johnrbarker.com>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
Co-authored-by: Deric Crago <deric.crago@gmail.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 70ba401602)

Co-authored-by: Martin <spleefer90@gmail.com>
This commit is contained in:
patchback[bot] 2020-12-02 08:17:26 +01:00 committed by GitHub
parent 6470d3defe
commit 961011891b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- icinga2_host - fix returning error codes (https://github.com/ansible-collections/community.general/pull/335).

View file

@ -289,7 +289,7 @@ def main():
if ret['code'] == 200:
changed = True
else:
module.fail_json(msg="bad return code deleting host: %s" % (ret['data']))
module.fail_json(msg="bad return code (%s) deleting host: '%s'" % (ret['code'], ret['data']))
except Exception as e:
module.fail_json(msg="exception deleting host: " + str(e))
@ -305,7 +305,7 @@ def main():
if ret['code'] == 200:
changed = True
else:
module.fail_json(msg="bad return code modifying host: %s" % (ret['data']))
module.fail_json(msg="bad return code (%s) modifying host: '%s'" % (ret['code'], ret['data']))
else:
if state == "present":
@ -317,7 +317,7 @@ def main():
if ret['code'] == 200:
changed = True
else:
module.fail_json(msg="bad return code creating host: %s" % (ret['data']))
module.fail_json(msg="bad return code (%s) creating host: '%s'" % (ret['code'], ret['data']))
except Exception as e:
module.fail_json(msg="exception creating host: " + str(e))