From 58745024eb892bda1cb9fe4ff4d1db5b7277eca1 Mon Sep 17 00:00:00 2001 From: Bodo Schulz Date: Tue, 12 Nov 2024 15:50:01 +0100 Subject: [PATCH] fix module --- .github/workflows/loki.yml | 2 ++ plugins/modules/loki_verify_config.py | 28 ++++++++++++------- .../loki/molecule/2.6/group_vars/all/vars.yml | 14 ++++++++++ .../loki/molecule/2.7/group_vars/all/vars.yml | 16 ++++++++++- roles/loki/vars/main.yml | 10 +++---- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/.github/workflows/loki.yml b/.github/workflows/loki.yml index 869fa11..62d0aa9 100644 --- a/.github/workflows/loki.yml +++ b/.github/workflows/loki.yml @@ -170,6 +170,8 @@ jobs: - with-updates - "2.5" - "2.6" + - "2.7" + - "3.2" collection_role: - loki diff --git a/plugins/modules/loki_verify_config.py b/plugins/modules/loki_verify_config.py index 5d649ef..316aeaa 100644 --- a/plugins/modules/loki_verify_config.py +++ b/plugins/modules/loki_verify_config.py @@ -77,20 +77,28 @@ def run(self): rc, out, err = self.__exec(args, check_rc=False) + err = err.strip() + # self.module.log(msg=f" -> '{err}' ({type(err)})") + if rc == 0: _failed = False - if isinstance(err, str): - err = json.loads(err) - - if isinstance(err, dict): - error_msg = err.get("err", None) - msg = err.get("msg", None) - - if rc != 0 and error_msg: - msg = error_msg.split("\n") + if rc != 0 and len(err) > 0: + if isinstance(err, str): + err = json.loads(err) + + if isinstance(err, dict): + # log_level = err.get("level", "info") + error_msg = err.get("err", None) + msg = err.get("msg", None) + # if log_level == "warn": + # msg = error_msg = err.get("msg", None) + if rc != 0 and error_msg: + msg = error_msg.split("\n") + else: + msg = err else: - msg = err + msg = "unknow config error." result = dict( failed=_failed, diff --git a/roles/loki/molecule/2.6/group_vars/all/vars.yml b/roles/loki/molecule/2.6/group_vars/all/vars.yml index cd5c50a..2d0b40b 100644 --- a/roles/loki/molecule/2.6/group_vars/all/vars.yml +++ b/roles/loki/molecule/2.6/group_vars/all/vars.yml @@ -6,4 +6,18 @@ loki_config_server: http_listen_address: "127.0.0.1" http_listen_port: 3100 +loki_config_schema: + configs: + - from: "2020-10-24" + store: boltdb # tsdb # + object_store: filesystem + schema: v11 # v13 # + index: + prefix: index_ + period: 168h # 24h # + chunks: + prefix: index_ + period: 168h + row_shards: 16 + ... diff --git a/roles/loki/molecule/2.7/group_vars/all/vars.yml b/roles/loki/molecule/2.7/group_vars/all/vars.yml index cd5c50a..c3fdf9f 100644 --- a/roles/loki/molecule/2.7/group_vars/all/vars.yml +++ b/roles/loki/molecule/2.7/group_vars/all/vars.yml @@ -1,9 +1,23 @@ --- -loki_version: "2.6.1" +loki_version: "2.7.4" loki_config_server: http_listen_address: "127.0.0.1" http_listen_port: 3100 +loki_config_schema: + configs: + - from: "2020-10-24" + store: boltdb # tsdb # + object_store: filesystem + schema: v11 # v13 # + index: + prefix: index_ + period: 168h # 24h # + chunks: + prefix: index_ + period: 168h + row_shards: 16 + ... diff --git a/roles/loki/vars/main.yml b/roles/loki/vars/main.yml index bfbc20d..13bc481 100644 --- a/roles/loki/vars/main.yml +++ b/roles/loki/vars/main.yml @@ -224,16 +224,16 @@ loki_defaults_config_chunk_store: {} loki_defaults_config_schema: configs: - - from: "2020-10-24" - store: boltdb # tsdb # + - from: "2024-01-01" + store: tsdb # tsdb # object_store: filesystem - schema: v11 # v13 # + schema: v13 # v13 # index: prefix: index_ - period: 168h # 24h # + period: 24h # 24h # chunks: prefix: index_ - period: 168h + period: 24h row_shards: 16 loki_defaults_config_limits: