From 133dda31d1157aff0230ee2637f42ab5813fd765 Mon Sep 17 00:00:00 2001 From: pavel Date: Thu, 30 Jul 2026 17:58:30 +0300 Subject: [PATCH] 1758 --- files/ansible-playbooks/sot-updater-offp.yml | 44 +++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/files/ansible-playbooks/sot-updater-offp.yml b/files/ansible-playbooks/sot-updater-offp.yml index fe95fc2..8183961 100644 --- a/files/ansible-playbooks/sot-updater-offp.yml +++ b/files/ansible-playbooks/sot-updater-offp.yml @@ -1256,6 +1256,46 @@ }} # ----------------------- Cloud offboard provisioning telemetry ----------------------- + - name: Cloud offboard provisioning | Resolve bearer used by nb_onedevice_update.py + delegate_to: localhost + environment: + OFFP_CLOUD_BEARER: "{{ cloud_bearer | default('') }}" + shell: | + if [ -n "${OFFP_CLOUD_BEARER:-}" ]; then + printf '%s\n' "$OFFP_CLOUD_BEARER" + exit 0 + fi + + python3 - <<'PY' + import ast + from pathlib import Path + + path = Path('/opt/containers/ansible-worker/app/nb_onedevice_update.py') + tree = ast.parse(path.read_text()) + + for node in tree.body: + if not isinstance(node, ast.Assign): + continue + if any(isinstance(target, ast.Name) and target.id == 'CLOUD_BEARER' for target in node.targets): + value = ast.literal_eval(node.value) + if isinstance(value, str) and value: + print(value) + raise SystemExit(0) + + raise SystemExit(1) + PY + args: + executable: /bin/bash + register: offp_cloud_bearer_cmd + changed_when: false + failed_when: false + + - name: Cloud offboard provisioning | Set bearer fact + delegate_to: localhost + set_fact: + offp_cloud_bearer: "{{ offp_cloud_bearer_cmd.stdout | default('') | trim }}" + changed_when: false + - name: Cloud offboard provisioning | Resolve cloud_id and initialize values delegate_to: localhost set_fact: @@ -1280,13 +1320,13 @@ - name: Cloud offboard provisioning | Read reported config when: - (offp_cloud_id | default('') | length) > 0 - - (cloud_bearer | default('') | length) > 0 + - (offp_cloud_bearer | default('') | length) > 0 delegate_to: localhost uri: url: "{{ cloud_config_base }}/{{ offp_cloud_id }}/config" method: GET headers: - Authorization: "Bearer {{ cloud_bearer }}" + Authorization: "Bearer {{ offp_cloud_bearer }}" Accept: "application/json" return_content: true status_code: 200