diff --git a/plugins/modules/grafana_silence.py b/plugins/modules/grafana_silence.py index 1b2b7091..d995d5cd 100644 --- a/plugins/modules/grafana_silence.py +++ b/plugins/modules/grafana_silence.py @@ -271,12 +271,17 @@ def organization_by_name(self, org_name): def get_version(self): url = "/api/health" response = self._send_request( - url, data=None, headers=self.headers, method="GET" + url, data=None, headers=self.headers, method="GET" ) version = response.get("version") if version is not None: - major, minor, rev = version.split(".") - return {"major": int(major), "minor": int(minor), "rev": int(rev)} + try: + # Split the version by '-' to handle the build number + version_main, build_number = version.split("-") + major, minor, rev = version_main.split(".") + return {"major": int(major), "minor": int(minor), "rev": int(rev), "build": build_number} + except ValueError: + raise GrafanaError(f"Unexpected version format: '{version}'") raise GrafanaError("Failed to retrieve version from '%s'" % url) def create_silence(self, comment, created_by, starts_at, ends_at, matchers):