diff --git a/changelogs/fragments/335-icinga2_host-return-error-code.yaml b/changelogs/fragments/335-icinga2_host-return-error-code.yaml new file mode 100644 index 0000000000..26e2d2f5c9 --- /dev/null +++ b/changelogs/fragments/335-icinga2_host-return-error-code.yaml @@ -0,0 +1,2 @@ +bugfixes: + - icinga2_host - fix returning error codes (https://github.com/ansible-collections/community.general/pull/335). diff --git a/plugins/modules/monitoring/icinga2_host.py b/plugins/modules/monitoring/icinga2_host.py index 6bdbb7179c..e2acdb2a6a 100644 --- a/plugins/modules/monitoring/icinga2_host.py +++ b/plugins/modules/monitoring/icinga2_host.py @@ -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))