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

with_pipe doesn't grok line breaks #11454

Closed
jan-grant opened this issue Jul 1, 2015 · 2 comments
Closed

with_pipe doesn't grok line breaks #11454

jan-grant opened this issue Jul 1, 2015 · 2 comments
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release

Comments

@jan-grant
Copy link

- hosts: localhost
  vars:
    dir: /tmp/bar
  tasks:
    - file:
        dest: "{{ dir }}"
        state: absent
    - file:
        dest: "{{ dir }}/{{item}}"
        state: directory
      with_items:
        - a
        - b
        - c
    - debug:
        var: item
      with_pipe: find {{ dir }} -maxdepth 1 -mindepth 1 -type d

A single item is returned, which contains all the output of find (with embedded newlines).

@jan-grant
Copy link
Author

A more stable test that doesn't rely on the filesystem:

- hosts: localhost
  tasks:
    - debug:
        var: item
      with_pipe: printf 'a\nb\nc'

@bcoca bcoca added bug_report P2 Priority 2 - Issue Blocks Release labels Jul 1, 2015
@jimi-c
Copy link
Member

jimi-c commented Jul 21, 2015

Hi @jan-grant, you can use with_lines or use lookup('pipe', ...).split('\n') to get the lines. The with_pipe lookup will always return the raw output of the command only.

If you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@jimi-c jimi-c closed this as completed Jul 21, 2015
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release
Projects
None yet
Development

No branches or pull requests

4 participants