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

Trailing newline added to stdout #23730

Closed
jcgarrido opened this issue Apr 19, 2017 · 2 comments
Closed

Trailing newline added to stdout #23730

jcgarrido opened this issue Apr 19, 2017 · 2 comments
Assignees
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community

Comments

@jcgarrido
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

stdout from script module in Windows

ANSIBLE VERSION
ansible 2.3.0.0
  config file = /home/juancarlos/shared/Git/bitbucket/edosdp-ansible-roles/pbotools/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.6.6 (r266:84292, Aug 18 2016, 14:53:48) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
CONFIGURATION
[defaults]
host_key_checking = False

log_path = /home/juancarlos/shared/ansible.log
OS / ENVIRONMENT

Running Ansible from CentOS 6.8
Managing Windows 2012 servers

SUMMARY

Ansible 2.3.0 is adding a traling newline to stdout, and this is making some string comparisons fail.

This does not happen with Ansible 2.2.1, because that version does not append newline to stdout.

STEPS TO REPRODUCE

Use the script module to run a powershell script in Windows and register the output. For example:

- name: Check version installed
  script: ./powershell_scripts/compareVersion.ps1 "{{ guid[tool] }}" "{{ installer_version | default('0.0') }}" -executionpolicy remotesigned
  register: check_version

EXPECTED RESULTS

With Ansible 2.2.1 we don't have a trailing newline in stdout:

2017-04-19 10:03:59,523 p=5261 u=juancarlos |  ok: [eselivrnd248] => {
    "check_version": {
        "changed": true, 
        "rc": 0, 
        "stderr": "", 
        "stdout": "notinstalled", 
        "stdout_lines": [
            "notinstalled"
        ]
    }
} 

ACTUAL RESULTS

With Ansible 2.3.0 we have a trailing newline in stdout:

2017-04-19 10:15:49,485 p=5592 u=juancarlos |  ok: [eselivrnd248] => {
    "changed": false, 
    "check_version": {
        "changed": true, 
        "rc": 0, 
        "stderr": "", 
        "stdout": "notinstalled\r\n", 
        "stdout_lines": [
            "notinstalled"
        ]
    }
}

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Apr 19, 2017
@gundalow gundalow removed the needs_triage Needs a first human triage before being processed. label Apr 19, 2017
@gundalow gundalow added this to the 2.3.0 milestone Apr 19, 2017
@gundalow
Copy link
Contributor

@jcgarrido Thanks for this.

Marking as 2.3 blocking as it's a regression

@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@abadger abadger added the windows Windows community label Aug 8, 2017
@bcoca bcoca modified the milestone: 2.3.0 Sep 6, 2017
@jborean93
Copy link
Contributor

I believe this change was made to align the script module with win_command and win_shell. It could also potentially be due to the change in the exec wrapper but I don't believe we want to revert back to the older behaviour. If you still wish to compare string without the last \r\n you can always do {{result.stdout_lines|join("\r\n")}} to achieve the same result.

Going to close the ticket as this is the intended behaviour.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community
Projects
None yet
Development

No branches or pull requests

7 participants