Update Sharepoint.yaml
This commit is contained in:
@@ -133,33 +133,56 @@
|
|||||||
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 ---
|
# --- Create list item (no block/rescue; use ignore_errors + diagnostics) ---
|
||||||
- name: Create SharePoint list item (Graph)
|
- name: Create SharePoint list item (Graph)
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
block:
|
uri:
|
||||||
- uri:
|
url: "https://graph.microsoft.com/v1.0/sites/{{ site_id }}/lists/{{ list_id }}/items"
|
||||||
url: "https://graph.microsoft.com/v1.0/sites/{{ site_id }}/lists/{{ list_id }}/items"
|
method: POST
|
||||||
method: POST
|
headers:
|
||||||
headers:
|
Authorization: "Bearer {{ graph_token.json.access_token }}"
|
||||||
Authorization: "Bearer {{ graph_token.json.access_token }}"
|
Content-Type: "application/json"
|
||||||
Content-Type: "application/json"
|
body_format: json
|
||||||
body_format: json
|
return_content: true
|
||||||
return_content: true
|
status_code: [200, 201]
|
||||||
status_code: [200, 201]
|
body:
|
||||||
body:
|
fields:
|
||||||
fields:
|
Title: "{{ job_name }} ({{ job_id }})"
|
||||||
Title: "{{ job_name }} ({{ job_id }})"
|
Status: "{{ status }}"
|
||||||
Status: "{{ status }}"
|
RunStart: "{{ run_start }}"
|
||||||
RunStart: "{{ run_start }}"
|
RunEnd: "{{ run_end }}"
|
||||||
RunEnd: "{{ run_end }}"
|
Notes: |-
|
||||||
Notes: |-
|
{{ summary_text }}
|
||||||
{{ summary_text }}
|
Recap: {{ hostvars['localhost'].recap_line }}
|
||||||
Recap: {{ hostvars['localhost'].recap_line }}
|
register: sp_create
|
||||||
register: sp_create
|
ignore_errors: true
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
rescue:
|
- name: Show sanitized Graph error (if any)
|
||||||
- name: Sanitize and print the error
|
run_once: true
|
||||||
run_once: true
|
when: sp_create is failed
|
||||||
|
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.
|
||||||
|
|
||||||
|
- name: Fail if SharePoint item was not created
|
||||||
|
run_once: true
|
||||||
|
when: sp_create is failed
|
||||||
|
fail:
|
||||||
|
msg: "Failed to create SharePoint item (see previous message)."
|
||||||
|
|
||||||
|
- name: Show created list item id
|
||||||
|
run_once: true
|
||||||
|
when: sp_create is succeeded
|
||||||
|
debug:
|
||||||
|
var: sp_create.json.id
|
||||||
Reference in New Issue
Block a user