Update Sharepoint.yaml
This commit is contained in:
@@ -63,20 +63,17 @@
|
|||||||
vars:
|
vars:
|
||||||
stats: "{{ (_recap.json.results | default([])) | first | default({}) }}"
|
stats: "{{ (_recap.json.results | default([])) | first | default({}) }}"
|
||||||
data: "{{ stats.event_data | default({}) }}"
|
data: "{{ stats.event_data | default({}) }}"
|
||||||
# event_data keys are dicts {host: count}; sum values safely
|
|
||||||
sumdict: >-
|
|
||||||
{% set ns = namespace(t=0) -%}
|
|
||||||
{%- for v in (item | default({})).values() -%}{%- set ns.t = ns.t + (v|int) -%}{%- endfor -%}
|
|
||||||
{{ ns.t }}
|
|
||||||
set_fact:
|
set_fact:
|
||||||
recap_ok: "{{ sumdict | from_yaml(item=data.ok) }}"
|
recap_ok: "{{ (data.ok | default({})) | dict2items | map(attribute='value') | map('int') | sum }}"
|
||||||
recap_changed: "{{ sumdict | from_yaml(item=data.changed) }}"
|
recap_changed: "{{ (data.changed | default({})) | dict2items | map(attribute='value') | map('int') | sum }}"
|
||||||
recap_failed: "{{ sumdict | from_yaml(item=data.failures) }}"
|
recap_failed: "{{ (data.failures | default({})) | dict2items | map(attribute='value') | map('int') | sum }}"
|
||||||
recap_skipped: "{{ sumdict | from_yaml(item=data.skipped) }}"
|
recap_skipped: "{{ (data.skipped | default({})) | dict2items | map(attribute='value') | map('int') | sum }}"
|
||||||
recap_unreach: "{{ sumdict | from_yaml(item=data.dark) }}"
|
recap_unreach: "{{ (data.dark | default({})) | dict2items | map(attribute='value') | map('int') | sum }}"
|
||||||
|
|
||||||
- name: Build SharePoint recap line
|
- name: Build SharePoint recap line (store on localhost for later use)
|
||||||
run_once: true
|
run_once: true
|
||||||
|
delegate_to: localhost
|
||||||
|
delegate_facts: true
|
||||||
set_fact:
|
set_fact:
|
||||||
recap_line: >-
|
recap_line: >-
|
||||||
OK={{ recap_ok | default(0) }},
|
OK={{ recap_ok | default(0) }},
|
||||||
@@ -85,6 +82,7 @@
|
|||||||
Skipped={{ recap_skipped | default(0) }},
|
Skipped={{ recap_skipped | default(0) }},
|
||||||
Unreachable={{ recap_unreach | default(0) }}
|
Unreachable={{ recap_unreach | default(0) }}
|
||||||
|
|
||||||
|
# --- Optional probes (keep while debugging) ---
|
||||||
- name: Verify siteId resolves
|
- name: Verify siteId resolves
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
@@ -109,7 +107,7 @@
|
|||||||
return_content: true
|
return_content: true
|
||||||
status_code: 200
|
status_code: 200
|
||||||
register: lists_probe
|
register: lists_probe
|
||||||
no_log: false
|
no_log: true
|
||||||
|
|
||||||
- name: Show lists (sanitized)
|
- name: Show lists (sanitized)
|
||||||
run_once: true
|
run_once: true
|
||||||
@@ -127,18 +125,15 @@
|
|||||||
return_content: true
|
return_content: true
|
||||||
status_code: 200
|
status_code: 200
|
||||||
register: cols_probe
|
register: cols_probe
|
||||||
no_log: false
|
no_log: true
|
||||||
|
|
||||||
- name: Print internal names
|
|
||||||
run_once: true
|
|
||||||
debug:
|
|
||||||
var: cols_probe.json.value | map(attribute='name') | list
|
|
||||||
|
|
||||||
- name: Show internal column names (safe)
|
- name: Show internal column names (safe)
|
||||||
|
run_once: true
|
||||||
debug:
|
debug:
|
||||||
msg:
|
msg:
|
||||||
names: "{{ (cols_probe.json.value | default([])) | map(attribute='name') | list }}"
|
names: "{{ (cols_probe.json.value | default([])) | map(attribute='name') | list }}"
|
||||||
|
|
||||||
|
# --- Create list item ---
|
||||||
- name: Create SharePoint list item (Graph)
|
- name: Create SharePoint list item (Graph)
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
@@ -160,29 +155,11 @@
|
|||||||
RunEnd: "{{ run_end }}"
|
RunEnd: "{{ run_end }}"
|
||||||
Notes: |-
|
Notes: |-
|
||||||
{{ summary_text }}
|
{{ summary_text }}
|
||||||
Recap: {{ recap_line }}
|
Recap: {{ hostvars['localhost'].recap_line }}
|
||||||
register: sp_create
|
register: sp_create
|
||||||
no_log: false
|
no_log: true
|
||||||
|
|
||||||
rescue:
|
rescue:
|
||||||
- name: Sanitize and print the error
|
- name: Sanitize and print the error
|
||||||
run_once: true
|
run_once: true
|
||||||
vars:
|
|
||||||
_json: "{{ sp_create.json | default({}) }}"
|
|
||||||
debug:
|
|
||||||
msg:
|
|
||||||
status: "{{ sp_create.status | default('n/a') }}"
|
|
||||||
graph_error: >-
|
|
||||||
{{ _json.error.message
|
|
||||||
| default(_json.message
|
|
||||||
| default(sp_create.msg | default('Unknown error'))) }}
|
|
||||||
hint: >
|
|
||||||
400: column internal names; 401: scope/audience; 403: permissions;
|
|
||||||
404: siteId/listId.
|
|
||||||
- fail:
|
|
||||||
msg: "Failed to create SharePoint item (see previous message)."
|
|
||||||
|
|
||||||
- name: Show created list item id
|
|
||||||
run_once: true
|
|
||||||
debug:
|
|
||||||
var: sp_create.json.id
|
|
||||||
|
|||||||
Reference in New Issue
Block a user