Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_powershell: $Ansible.Result can no longer be set to an empty list #686

Closed
JosedeLeon85 opened this issue Oct 31, 2024 · 1 comment · Fixed by #711
Closed

win_powershell: $Ansible.Result can no longer be set to an empty list #686

JosedeLeon85 opened this issue Oct 31, 2024 · 1 comment · Fixed by #711

Comments

@JosedeLeon85
Copy link

JosedeLeon85 commented Oct 31, 2024

SUMMARY

It is no longer possible to set $Ansible.Result to an empty list, it gets changed to null. The problem started on v2.5.0.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • win_powershell
ANSIBLE VERSION
ansible [core 2.17.5]
  config file = /root/user1/my-repo/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.12/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/usr/bin/python3.12)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
# /usr/local/lib/python3.12/dist-packages/ansible_collections
Collection      Version
--------------- -------
ansible.windows 2.5.0  
OS / ENVIRONMENT
  • Windows 2022
STEPS TO REPRODUCE
  • Set $Ansible.Result to an empty list
- name: Reproduce bug in ansible.windows.win_powershell
  hosts: server_name.domain
  connection: psrp
  gather_facts: false
  tasks:
    - name: Set $Ansible.Result to an empty list
      ansible.windows.win_powershell:
        error_action: stop
        script: $Ansible.Result = @()
      register: script_result

    - name: Print result
      debug:
        var: script_result
EXPECTED RESULTS
  • result should be an empty list:
{
    "script_result": {
        "changed": true,
        "debug": [],
        "error": [],
        "failed": false,
        "host_err": "",
        "host_out": "",
        "information": [],
        "output": [],
        "result": [],
        "verbose": [],
        "warning": []
    }
}
ACTUAL RESULTS
  • result is set to null
{
    "script_result": {
        "changed": true,
        "debug": [],
        "error": [],
        "failed": false,
        "host_err": "",
        "host_out": "",
        "information": [],
        "output": [],
        "result": null,
        "verbose": [],
        "warning": []
    }
}
@jborean93
Copy link
Collaborator

Sorry for the delay in responding. I've opened #711 which fixes this bug and returns the behavior back to how it was before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants