From 1cb0c3d8148796888c394fd3adbf3d976c2bbcc2 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Mon, 3 May 2021 11:24:43 +0200 Subject: [PATCH] Fix issue when noise neaks into get_python_info.py script stdout Change-Id: I36f9e80199115b628993814f8751ce834f84f467 --- roles/tobiko-ensure-python3/files/get_python_info.py | 3 ++- roles/tobiko-ensure-python3/tasks/install.yaml | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/roles/tobiko-ensure-python3/files/get_python_info.py b/roles/tobiko-ensure-python3/files/get_python_info.py index 1ad07af46..413baeb78 100644 --- a/roles/tobiko-ensure-python3/files/get_python_info.py +++ b/roles/tobiko-ensure-python3/files/get_python_info.py @@ -50,7 +50,8 @@ def main(): info = {'version': version, 'executable': sys.executable, 'executables': executables} - output = json.dumps(info, indent=4, sort_keys=True) + output = json.dumps(info) + assert output.startswith('{') print(output) diff --git a/roles/tobiko-ensure-python3/tasks/install.yaml b/roles/tobiko-ensure-python3/tasks/install.yaml index c969ad0a9..a77cc6c40 100644 --- a/roles/tobiko-ensure-python3/tasks/install.yaml +++ b/roles/tobiko-ensure-python3/tasks/install.yaml @@ -34,14 +34,17 @@ cmd: get_python_info.py --base --quiet executable: '{{ get_python_exe.stdout_lines | first }}' register: get_python_info - changed_when: no + changed_when: false - name: "set python_info['{{ python_command }}'] fact" set_fact: python_info: > {{ python_info | combine({python_command: - (get_python_info.stdout | from_json)}) }} + (item | from_json)}) }} + loop: '{{ get_python_info.stdout_lines }}' + when: item.startswith('{') + failed_when: (python_info | length) == 0 - name: "upgrade '{{ python_command }}' packages to the latest versions"