1758
This commit is contained in:
@@ -1256,6 +1256,46 @@
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
# ----------------------- Cloud offboard provisioning telemetry -----------------------
|
# ----------------------- 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
|
- name: Cloud offboard provisioning | Resolve cloud_id and initialize values
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
set_fact:
|
set_fact:
|
||||||
@@ -1280,13 +1320,13 @@
|
|||||||
- name: Cloud offboard provisioning | Read reported config
|
- name: Cloud offboard provisioning | Read reported config
|
||||||
when:
|
when:
|
||||||
- (offp_cloud_id | default('') | length) > 0
|
- (offp_cloud_id | default('') | length) > 0
|
||||||
- (cloud_bearer | default('') | length) > 0
|
- (offp_cloud_bearer | default('') | length) > 0
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
uri:
|
uri:
|
||||||
url: "{{ cloud_config_base }}/{{ offp_cloud_id }}/config"
|
url: "{{ cloud_config_base }}/{{ offp_cloud_id }}/config"
|
||||||
method: GET
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
Authorization: "Bearer {{ cloud_bearer }}"
|
Authorization: "Bearer {{ offp_cloud_bearer }}"
|
||||||
Accept: "application/json"
|
Accept: "application/json"
|
||||||
return_content: true
|
return_content: true
|
||||||
status_code: 200
|
status_code: 200
|
||||||
|
|||||||
Reference in New Issue
Block a user