From 84d9f30d5d100ba3efcd0e21b8be9ac88dc6aca1 Mon Sep 17 00:00:00 2001 From: Sylvain Roche Date: Mon, 28 May 2018 12:24:32 +0200 Subject: [PATCH 1/5] Update statuscake_uptime.py ContactGroup should be a string, which allows to set multiple contact group IDs (comma separation for multiple ID) according to cf. https://www.statuscake.com/api/Tests/Updating%20Inserting%20and%20Deleting%20Tests.md --- library/statuscake_uptime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/statuscake_uptime.py b/library/statuscake_uptime.py index 369b7c4..2c7da7d 100755 --- a/library/statuscake_uptime.py +++ b/library/statuscake_uptime.py @@ -406,7 +406,7 @@ def run_module(): check_rate=dict(type='int', required=False), test_type=dict(type='str', required=False), port=dict(type='int', required=False), - contact_group=dict(type='int', required=False), + contact_group=dict(type='str', required=False), paused=dict(type='int', required=False), node_locations=dict(type='str', required=False), confirmation=dict(type='int', required=False), From 4feb09ae7d1347589e91a64d12adbdad117d1a3c Mon Sep 17 00:00:00 2001 From: Sylvain Roche Date: Tue, 12 Mar 2019 16:41:48 +0100 Subject: [PATCH 2/5] add http authentication management --- library/statuscake_uptime.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/library/statuscake_uptime.py b/library/statuscake_uptime.py index 2c7da7d..0a38bed 100755 --- a/library/statuscake_uptime.py +++ b/library/statuscake_uptime.py @@ -123,6 +123,14 @@ description: - Use to populate the RAW POST data field on the test required: false + basic_user: + description: + - A Basic Auth User account to use to login + required: false + basic_pass: + description: + - If BasicUser is set then this should be the password for the BasicUser + required: false ''' EXAMPLES = ''' @@ -149,6 +157,8 @@ find_string: "/html>" do_not_find: 0 post_raw: "" + basic_user: "my_username" + basic_pass: "my_password" - name: List all statuscake tests statuscake: @@ -221,7 +231,7 @@ def __init__(self, module, username, api_key, name, url, state, test_tags, check_rate, test_type, port, contact_group, paused, node_locations, confirmation, timeout, status_codes, host, custom_header, follow_redirect, find_string, do_not_find, - post_raw): + post_raw, basic_user, basic_pass): self.headers = {"Username": username, "API": api_key} self.module = module @@ -243,6 +253,8 @@ def __init__(self, module, username, api_key, name, url, state, self.do_not_find = do_not_find self.port = port self.post_raw = post_raw + self.basic_user = basic_user + self.basic_pass = basic_pass if not check_rate: self.check_rate = 300 @@ -270,6 +282,8 @@ def __init__(self, module, username, api_key, name, url, state, "FindString": self.find_string, "Port": self.port, "DoNotFind": self.do_not_find, + "BasicUser": self.basic_user, + "BasicPass": self.basic_pass, } if self.custom_header: @@ -418,6 +432,8 @@ def run_module(): find_string=dict(type='str', required=False), do_not_find=dict(type='int', required=False), post_raw=dict(type='str', required=False), + basic_user=dict(type='str', required=False), + basic_pass=dict(type='str', required=False), ) module = AnsibleModule( @@ -451,6 +467,8 @@ def run_module(): find_string = module.params['find_string'] do_not_find = module.params['do_not_find'] post_raw = module.params['post_raw'] + basic_user = module.params['basic_user'] + basic_pass = module.params['basic_pass'] if not (username and api_key) and \ os.environ.get('STATUSCAKE_USERNAME') and \ @@ -485,7 +503,9 @@ def run_module(): follow_redirect, find_string, do_not_find, - post_raw) + post_raw, + basic_user, + basic_pass) if state == "absent": test.delete_test() From 6142cb3988fe08d86b7c04d0d8884149499101c5 Mon Sep 17 00:00:00 2001 From: Sylvain Roche Date: Tue, 12 Mar 2019 16:47:42 +0100 Subject: [PATCH 3/5] =?UTF-8?q?fix=20statuscake=20AP=C3=8F=20not=20recover?= =?UTF-8?q?ing=20http=20auth=20infos=20in=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/statuscake_uptime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/statuscake_uptime.py b/library/statuscake_uptime.py index 0a38bed..b0d3135 100755 --- a/library/statuscake_uptime.py +++ b/library/statuscake_uptime.py @@ -365,7 +365,7 @@ def create_test(self): str(test_id)) response = requests.get(url_details_test, headers=self.headers) req_data = self.convert(response.json()) - diffkeys = ([k for k in self.data if self.data[k] and + diffkeys = ([k for k in self.data if self.data[k] and k in req_data and str(self.data[k]) != str(req_data[k])]) if self.module.check_mode: if len(diffkeys) != 0: From 9f35fb1332f70aa324b29aa7afd49ea1ccfcbe25 Mon Sep 17 00:00:00 2001 From: Sylvain Roche Date: Tue, 12 Mar 2019 18:19:36 +0100 Subject: [PATCH 4/5] merge conflict trigger_rate --- library/statuscake_uptime.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/library/statuscake_uptime.py b/library/statuscake_uptime.py index b0d3135..a3ed7f7 100755 --- a/library/statuscake_uptime.py +++ b/library/statuscake_uptime.py @@ -123,6 +123,10 @@ description: - Use to populate the RAW POST data field on the test required: false + trigger_rate: + description: + - Alert delay rate + default: 5 basic_user: description: - A Basic Auth User account to use to login @@ -157,6 +161,7 @@ find_string: "/html>" do_not_find: 0 post_raw: "" + trigger_rate: 0 basic_user: "my_username" basic_pass: "my_password" @@ -231,7 +236,7 @@ def __init__(self, module, username, api_key, name, url, state, test_tags, check_rate, test_type, port, contact_group, paused, node_locations, confirmation, timeout, status_codes, host, custom_header, follow_redirect, find_string, do_not_find, - post_raw, basic_user, basic_pass): + post_raw, trigger_rate, basic_user, basic_pass): self.headers = {"Username": username, "API": api_key} self.module = module @@ -253,6 +258,7 @@ def __init__(self, module, username, api_key, name, url, state, self.do_not_find = do_not_find self.port = port self.post_raw = post_raw + self.trigger_rate = trigger_rate self.basic_user = basic_user self.basic_pass = basic_pass @@ -282,6 +288,7 @@ def __init__(self, module, username, api_key, name, url, state, "FindString": self.find_string, "Port": self.port, "DoNotFind": self.do_not_find, + "TriggerRate": self.trigger_rate, "BasicUser": self.basic_user, "BasicPass": self.basic_pass, } @@ -432,6 +439,7 @@ def run_module(): find_string=dict(type='str', required=False), do_not_find=dict(type='int', required=False), post_raw=dict(type='str', required=False), + trigger_rate=dict(type='int', required=False), basic_user=dict(type='str', required=False), basic_pass=dict(type='str', required=False), ) @@ -467,6 +475,7 @@ def run_module(): find_string = module.params['find_string'] do_not_find = module.params['do_not_find'] post_raw = module.params['post_raw'] + trigger_rate = module.params['trigger_rate'] basic_user = module.params['basic_user'] basic_pass = module.params['basic_pass'] @@ -504,6 +513,7 @@ def run_module(): find_string, do_not_find, post_raw, + trigger_rate, basic_user, basic_pass) From 7884965960907c209caab9a23a8b2a6e9c06993f Mon Sep 17 00:00:00 2001 From: Sylvain Roche Date: Tue, 12 Mar 2019 18:26:13 +0100 Subject: [PATCH 5/5] fix no log on, http auth password --- library/statuscake_uptime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/statuscake_uptime.py b/library/statuscake_uptime.py index a3ed7f7..a16101c 100755 --- a/library/statuscake_uptime.py +++ b/library/statuscake_uptime.py @@ -441,7 +441,7 @@ def run_module(): post_raw=dict(type='str', required=False), trigger_rate=dict(type='int', required=False), basic_user=dict(type='str', required=False), - basic_pass=dict(type='str', required=False), + basic_pass=dict(type='str', required=False, no_log=True), ) module = AnsibleModule(