From 8ea56a7e1b7ffbd12637d746d9e8215ff560467b Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Sat, 22 Jun 2019 08:47:37 +0200 Subject: [PATCH] fix: add new return code for api with the version 5.10 --- CHANGELOG.md | 3 ++- module_utils/sensu_api.py | 2 +- test/integration/default/default.yml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f0518..409ef4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,11 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) ## [Unreleased] - feat: add labels in checks -- fix: create roles before users - feat: add a debug mode with sensu_no_log variable - feat: add mutators - feat: add sensu_agent_redact variable to add new redact keywords +- fix: add new return code for api with the version 5.10 +- fix: create roles before users - doc: add example in readme ## [1.1.0] - 2019-02-17 diff --git a/module_utils/sensu_api.py b/module_utils/sensu_api.py index eae5402..7696380 100644 --- a/module_utils/sensu_api.py +++ b/module_utils/sensu_api.py @@ -59,7 +59,7 @@ class SensuApi: raise Exception('Server return 500 error: {}'.format(r.text)) elif r.status_code == 401: raise Exception('Authentification has failed') - elif r.status_code != 200: + elif r.status_code not in [200, 201, 204]: raise Exception('Server return an unknown error: {}'.format(r.text)) def delete(self, path): diff --git a/test/integration/default/default.yml b/test/integration/default/default.yml index cd0f947..d8875cf 100644 --- a/test/integration/default/default.yml +++ b/test/integration/default/default.yml @@ -2,6 +2,7 @@ - hosts: default connection: local vars: + sensu_no_log: false sensu_backend: yes sensu_agent_redact: - supersecret