aboutsummaryrefslogtreecommitdiff
path: root/ansible/library
diff options
context:
space:
mode:
authorMichal Nasiadka <mnasiadka@gmail.com>2026-01-08 14:56:36 +0100
committerMichal Nasiadka <mnasiadka@gmail.com>2026-01-12 14:30:24 +0000
commiteffd154e04a56203296a46fcce0b1919ddd029fb (patch)
treedfd5df998224a5178af2a20b90344bd2fefcd2cb /ansible/library
parentf699a56a8ac9706c6c33edf00e5056f8ce1dc896 (diff)
downloadkolla-ansible-effd154e04a56203296a46fcce0b1919ddd029fb.tar.gz
kolla-ansible-effd154e04a56203296a46fcce0b1919ddd029fb.zip
kolla_toolbox: Add support for deprecation warnings
ansible-core 2.20 introduced some deprecation warnings in internal module functions and not all modules have adapted to new functionality, therefore kolla_toolbox invocations contain both deprecation warnings (or other warnings) and JSON blocks. This patch adds support for separating these and printing deprecation warnings using warn() function in AnsibleModule Closes-Bug: #2138234 Change-Id: I2008d9d8c85b2216036f5155e29f7e5db43832f0 Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
Diffstat (limited to 'ansible/library')
-rw-r--r--ansible/library/kolla_toolbox.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/ansible/library/kolla_toolbox.py b/ansible/library/kolla_toolbox.py
index d368eb67d..4062fcb6e 100644
--- a/ansible/library/kolla_toolbox.py
+++ b/ansible/library/kolla_toolbox.py
@@ -13,6 +13,7 @@
# limitations under the License.
import json
+import re
import traceback
from ansible.module_utils.basic import AnsibleModule
@@ -165,7 +166,22 @@ class KollaToolboxWorker():
def _process_container_output(self, output_raw: bytes) -> dict:
"""Convert raw bytes output from container.exec_run into dictionary."""
try:
- output_json = json.loads(output_raw.decode('utf-8'))
+ # Extract deprecation warning (if any)
+ warning_match = re.search(rb'\[DEPRECATION WARNING\].*',
+ output_raw)
+ if warning_match:
+ self.module.warn(warning_match.group(0).decode('utf-8'))
+
+ # Extract JSON block (including curly braces and content)
+ json_match = re.search(rb'\{.*\}', output_raw, re.DOTALL)
+ if json_match:
+ output_json = json.loads(json_match.group(0))
+ else:
+ self.module.fail_json(
+ msg=('Parsing kolla_toolbox JSON output failed - '
+ 'no JSON block in output')
+ )
+
except json.JSONDecodeError as e:
self.module.fail_json(
msg=f'Parsing kolla_toolbox JSON output failed: {e}'