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"'']'

On Wednesday, October 18, 2023 at 1:52:44 PM UTC+5:30 dulh...@mailbox.org 
wrote:

>   
> 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 
>   
>
> On 10/18/2023 8:02 AM CEST Veera <svee...@gmail.com> wrote: 
>   
>   
> 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 [] 
>
>  
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/24c474a8-d6fc-4f6c-82de-6c2e8e609a81n%40googlegroups.com.

Reply via email to