Filter_data manipulation of the debug output .

From the below debug module , I try filter the ouput

  • name: status of the output
    debug:
    msg: “status of {{serverName}} is {{ [9] | map(‘extract’, stat_out[0].split(‘,’)) }}”
    register: server_status

The output is

TASK [status of the output] *******************************************************************************************
ok: [localhost] =>
msg: ‘status of client11 is [’’ “Status”: “Completed”‘’]’

and when I try to still filter the output , but missing a delimiter (like cut -d: -f1).

Expecting the output as below .
msg: ‘status of the server client11.example.com is [Completed]’

Any String(Word) like Completed or Failed to be captured in

can you provide a bit more context, i.e. where does the variable stat_out comes from.
Or maybe even better prodvide what debugging the entire variable throws at you

debug:
var: stat_out

in order to see the data structur you are getting

Here is the stat_out details

  • ansible.builtin.set_fact:
    stat_out: “{{ uri_result[‘json’][‘resources’] | selectattr(‘name’, ‘==’,‘LinuxOsUpdateExtension’) | map(attribute=‘properties’) |map(attribute=‘instanceView’)|map(attribute=‘status’)|map(attribute=‘message’) }}”

TASK [debug] **************************************************************************************************************************
ok: [localhost] =>
msg:

  • ‘Extension Message: Action Completed. [ActivityId=xxxxxxxxxxxx], OperationResult: {“activityId”: “xxxxxxx-xxxxxx”, “sequenceNumber”: 0, “inputStartTime”: “2023-08-18T05:34:24.920507Z”, “lastModifiedTime”: “2023-08-18T06:01:56.188600Z”, “extensionTriggerTime”: “2023-08-18T05:34:57.745409Z”, “osName”: “CentOS”, “osVersion”: “9”, “action”: “Patching”, “actionStatus”: “Success”, “patchServiceUsed”: “YUM”, “errors”: null, “patchDetails”: {“rebootNeeded”: true, “rebootStatus”: “Completed”, “maintenanceWindowExceeded”: false, “retriggerCount”: 09, “notSelectedPatchCount”: 0, “pendingPatchCount”: 0, “installedPatchCount”: 16, “failedPatchCount”: 0, “patches”: “eJxxxxxxxxxxx==”,
    “excludedPatchCount”: 0}, “assessmentDetails”: {“countByCategory”: {“security”: 0, “other”: 0}, “totalCount”: 0, “patches”: “eJyLjgUAARUAuQ==”, “rebootPending”: null}, “logs”: “kgjhsdcgdgscf/Y”}’

  • name: status of the output
    debug:
    msg: “status of {{serverName}} is {{ [9] | map(‘extract’, stat_out[0].split(‘,’)) }}”
    register: server_status
    ignore_errors: yes

The output is

TASK [status of the output] *******************************************************************************************
ok: [localhost] =>
msg: ‘status of client11 is [’’ “Status”: “Completed”‘’]’