# Filter\_data manipulation of the debug  output .

**URL:** <https://forum.ansible.com/t/filter-data-manipulation-of-the-debug-output/38530>\
**Category:** Ansible Project\
**Created:** [October 18, 2023, 6:02am UTC](https://forum.ansible.com/t/filter-data-manipulation-of-the-debug-output/38530 "2023-10-18T06:02:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Veera](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/veera/32/4107_2.png) [@Veera](https://forum.ansible.com/u/Veera)\
**Post date:** [October 18, 2023, 6:02am UTC](https://forum.ansible.com/t/filter-data-manipulation-of-the-debug-output/38530/1 "2023-10-18T06:02:37Z")

</div>

> 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](http://client11.example.com) is [Completed]’

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

---

<div class="post-metadata">

**Author:** ![dulhaver](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulhaver/32/1061_2.png) [@dulhaver](https://forum.ansible.com/u/dulhaver)\
**Post date:** [October 18, 2023, 8:22am UTC](https://forum.ansible.com/t/filter-data-manipulation-of-the-debug-output/38530/2 "2023-10-18T08:22:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Veera](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/veera/32/4107_2.png) [@Veera](https://forum.ansible.com/u/Veera)\
**Post date:** [October 19, 2023, 7:35am UTC](https://forum.ansible.com/t/filter-data-manipulation-of-the-debug-output/38530/3 "2023-10-19T07:35:44Z")

</div>

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”‘’]’
