'How to read the value returned by a powershell script with ansible

I am trying the following Powershell script:

Function jello-code {
    return "jello"
}

jello-code

In Ansible playbook I have a task defined as

- name : run jello script.
  win_shell: C:Projects\scripts\jello.ps1
  args:
    chdir:  C:Projects\scripts
  register : script_return
- debug : msg = {{script_return.stdout}}

Currently the value shown by debug task is

ok: [clientmachine.com] => {
    "msg": "Hello world!"
}

I always get the same "Hello world!" message.

My goal is to do other tasks based on the value returned by the Powershell script.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source