# issue #615: 'fetch' with become: was internally using slurp.

- name: regression/issue_615_streaming_transfer.yml
  hosts: test-targets
  gather_facts: no
  # Without Mitogen this causes Ansible to use the slurp module, which is *slow*
  become: true
  vars:
    mitogen_ssh_compression: false
  tasks:
    - include_tasks: _mitogen_only.yml
    - block:
        - name: Create /tmp/512mb.zero
          shell: |
            dd if=/dev/zero of=/tmp/512mb.zero bs=1048576 count=512;
            chmod go= /tmp/512mb.zero
          args:
            creates: /tmp/512mb.zero

        - name: Fetch /tmp/512mb.zero
          fetch:
            src: /tmp/512mb.zero
            dest: /tmp/fetch-{{ inventory_hostname }}-512mb.zero
            flat: true

        - name: Cleanup /tmp/512mb.zero
          file:
            path: /tmp/512mb.zero
            state: absent

        - name: Cleanup fetched file
          file:
            path: /tmp/fetch-{{ inventory_hostname }}-512mb.zero
            state: absent
          become: false
          delegate_to: localhost
  tags:
    - issue_615
    - mitogen_only
