"Conditional result was False"

Viewed 54

I am using below ansible to store a json output in the result.This works if json outout is a dictionary, But if the json output is a list of dictionaries then the when condition is failing and no values are stored in result.stdout. Please can someone help me on this.

  - name: 'Get Patches Required'
    script: 'Calling a posh script'
    no_log: True
    register: result
  #- debug: var=result 
  - set_fact: PatchList={{ result.stdout }}
  
  - set_fact: PatchList={{ result.stdout | from_json }}
    when: '((PatchList is not none) and (PatchList != ""))'

Logs for failures mentioned below

TASK [Get Patches Required] ****************************************************
Tuesday 13 September 2022  00:09:24 -0400 (0:00:00.059)       0:12:48.501 ***** 
changed: [] => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": true}

TASK [set_fact] ****************************************************************
Tuesday 13 September 2022  00:09:42 -0400 (0:00:18.577)       0:13:07.078 ***** 
ok: [] => {"ansible_facts": {"PatchList": ""}, "changed": false}

TASK [set_fact] ****************************************************************
Tuesday 13 September 2022  00:09:42 -0400 (0:00:00.126)       0:13:07.205 ***** 
skipping: [] => {"changed": false, "skip_reason": "Conditional result was False"}
0 Answers
Related