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

multiline shell fails on FreeBSD #32853

Closed
Vladimir-csp opened this issue Nov 13, 2017 · 5 comments
Closed

multiline shell fails on FreeBSD #32853

Vladimir-csp opened this issue Nov 13, 2017 · 5 comments
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bsd BSD community bug This issue/PR relates to a bug. commands Commands category module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@Vladimir-csp
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

shell

ANSIBLE VERSION
ansible 2.4.0.0
CONFIGURATION
OS / ENVIRONMENT

FreeBSD 11.1-RELEASE-p1 server
FreeBSD 11.1-RELEASE-p1 client

SUMMARY

quoted multiline shell command is treated as separate commands.

STEPS TO REPRODUCE
- name: get server environment
  local_action: shell env
  register: server_env

- name: log play data
  shell: |
    echo "starting new play" | logger -p user.notice -t ansible.logger.new_play
    echo "{{ server_env.stdout }}" | logger -p user.notice -t ansible.logger.server_env
EXPECTED RESULTS

server_env.stdout multiline content gets piped into logger. This worked fine in ansible 2.3. And stilll works fine in 2.4 on Linux client.

ACTUAL RESULTS

Shell module fails.

"stderr": "Unmatched '\"'.\nSSH_CONNECTION=1.2.3.4: Command not found.\n_=/usr/bin/env: Command not found.\n... etc.

Each line of server_env.stdout is treated as separate command, despite all newlines are inside quotes.

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 13, 2017
@Vladimir-csp
Copy link
Author

Vladimir-csp commented Nov 13, 2017

OK, I figured out that this happens because shell module now uses csh instead of sh for some reason. Setting -e ansible_shell_type=sh does not help, but setting executable: /bin/sh in shell module itself is a workaround.

ansible_shell_type is unset and we have no mention of csh in ansible.cfg. Why has shell changed?

@vbotka
Copy link
Contributor

vbotka commented Nov 13, 2017

As a first step I always change the login shell to /bin/sh for the user at host.

You might want to review the discussion here at
#13179

@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Nov 13, 2017
@bcoca
Copy link
Member

bcoca commented Nov 13, 2017

I believe this was a bug introduced in 2.4.0, see if #31361 fixes this for you (will be in 2.4.2)

@bcoca bcoca added the needs_info This issue requires further information. Please answer any outstanding questions. label Nov 13, 2017
@Vladimir-csp
Copy link
Author

Testing this commit would take time.
Does the new logic default to sh if unset?

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Nov 14, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@dagwieers dagwieers added the bsd BSD community label Jan 18, 2019
@ansibot ansibot added the commands Commands category label Mar 7, 2019
@Vladimir-csp
Copy link
Author

No longer having this trouble.

@ansible ansible locked and limited conversation to collaborators Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bsd BSD community bug This issue/PR relates to a bug. commands Commands category module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

5 participants