<h5 dir="auto">ISSUE TYPE: Bug Report</h5>
<h5 dir="auto">COMPONENT NAME: win_copy module</h5>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">ansible 2.2.0.0<br>
config file = /etc/ansible/ansible.cfg<br>
configured module search path = Default w/o overrides</p>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">No changes</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Ubuntu 16.04 with ansible/ansible PPA</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">When copying a large file from local to a remote host, ansible crashed. Looks like a regression from fix <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="161603331" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/16392" data-hovercard-type="pull_request" data-hovercard-url="/ansible/ansible/pull/16392/hovercard" href="https://github.com/ansible/ansible/pull/16392">#16392</a>. Proposed fix worked in 2.1, however when updating to 2.2 the bug resurfaced despite having the fix merged.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Copy large file
  win_copy:
    src: largeinstallerfile2GB.zip
    dest: 'c:\install'"><pre class="notranslate"><code class="notranslate">- name: Copy large file
  win_copy:
    src: largeinstallerfile2GB.zip
    dest: 'c:\install'
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">TASK [windows : Copy largeinstallerfile2GB.zip] ***<br>
task path: /root/ansible-test/roles/windows/tasks/install.yml:6<br>
An exception occurred during task execution. The full traceback is:<br>
Traceback (most recent call last):<br>
File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 119, in run<br>
res = self._execute()<br>
File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 490, in _execute<br>
result = self._handler.run(task_vars=variables)<br>
File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/copy.py", line 153, in run<br>
source_full = self._loader.get_real_file(source_full)<br>
File "/usr/lib/python2.7/dist-packages/ansible/parsing/dataloader.py", line 402, in get_real_file<br>
if is_encrypted_file(f):<br>
File "/usr/lib/python2.7/dist-packages/ansible/parsing/vault/<strong>init</strong>.py", line 158, in is_encrypted_file<br>
b_vaulttext = to_bytes(to_text(vaulttext, encoding='ascii', errors='strict'), encoding='ascii', errors='strict')<br>
File "/usr/lib/python2.7/dist-packages/ansible/module_utils/_text.py", line 177, in to_text<br>
return obj.decode(encoding, errors)<br>
MemoryError</p>
<p dir="auto">fatal: [ago-win1]: FAILED! =&gt; {<br>
"failed": true,<br>
"msg": "Unexpected failure during module execution.",<br>
"stdout": ""<br>
}</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Ubuntu 14.04.4 LTS</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Got MemoryError when copy huge local file to remote.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ cat huge_copy.yml 

---
- hosts: all
  become: yes

  tasks:
    - name: Copy huge file
      copy: src=5gb dest=dst

$ dd if=/dev/zero of=5gb bs=1G count=5
5+0 records in
5+0 records out
5368709120 bytes (5.4 GB) copied, 206.341 s, 26.0 MB/s

$ ansible-playbook -i hosts huge_copy.yml"><pre class="notranslate"><code class="notranslate">$ cat huge_copy.yml 

---
- hosts: all
  become: yes

  tasks:
    - name: Copy huge file
      copy: src=5gb dest=dst

$ dd if=/dev/zero of=5gb bs=1G count=5
5+0 records in
5+0 records out
5368709120 bytes (5.4 GB) copied, 206.341 s, 26.0 MB/s

$ ansible-playbook -i hosts huge_copy.yml
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">Copied successfully.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook -i hosts huge_copy.yml -vvv
Using /etc/ansible/ansible.cfg as config file

PLAYBOOK: huge_copy.yml ********************************************************
1 plays in huge_copy.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
&lt;192.168.80.129&gt; ESTABLISH SSH CONNECTION FOR USER: ansible
&lt;192.168.80.129&gt; SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/y/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.80.129 '/bin/sh -c '&quot;'&quot;'( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686 `&quot; &amp;&amp; echo ansible-tmp-1466567672.43-71840509019686=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686 `&quot; ) &amp;&amp; sleep 0'&quot;'&quot;''
&lt;192.168.80.129&gt; PUT /tmp/tmp3Bk56k TO /home/ansible/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686/setup
&lt;192.168.80.129&gt; SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/y/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.80.129]'
&lt;192.168.80.129&gt; ESTABLISH SSH CONNECTION FOR USER: ansible
&lt;192.168.80.129&gt; SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/y/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.80.129 '/bin/sh -c '&quot;'&quot;'sudo -H -S -n -u root /bin/sh -c '&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'echo BECOME-SUCCESS-rmwgnaejatjdbjwnltokljxsdjjlhagx; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686/setup; rm -rf &quot;/home/ansible/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686/&quot; &gt; /dev/null 2&gt;&amp;1'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;'&quot;' &amp;&amp; sleep 0'&quot;'&quot;''
ok: [192.168.80.129]

TASK [Copy huge file] **********************************************************
task path: /home/y/nfvdv4-single/huge_copy.yml:6
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File &quot;/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py&quot;, line 124, in run
    res = self._execute()
  File &quot;/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py&quot;, line 446, in _execute
    result = self._handler.run(task_vars=variables)
  File &quot;/usr/lib/python2.7/dist-packages/ansible/plugins/action/copy.py&quot;, line 156, in run
    source_full = self._loader.get_real_file(source_full)
  File &quot;/usr/lib/python2.7/dist-packages/ansible/parsing/dataloader.py&quot;, line 334, in get_real_file
    data = f.read()
MemoryError

fatal: [192.168.80.129]: FAILED! =&gt; {&quot;failed&quot;: true, &quot;msg&quot;: &quot;Unexpected failure during module execution.&quot;, &quot;stdout&quot;: &quot;&quot;}

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @huge_copy.retry

PLAY RECAP *********************************************************************
192.168.80.129             : ok=1    changed=0    unreachable=0    failed=1  "><pre class="notranslate"><code class="notranslate">$ ansible-playbook -i hosts huge_copy.yml -vvv
Using /etc/ansible/ansible.cfg as config file

PLAYBOOK: huge_copy.yml ********************************************************
1 plays in huge_copy.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
&lt;192.168.80.129&gt; ESTABLISH SSH CONNECTION FOR USER: ansible
&lt;192.168.80.129&gt; SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/y/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.80.129 '/bin/sh -c '"'"'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686 `" &amp;&amp; echo ansible-tmp-1466567672.43-71840509019686="` echo $HOME/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686 `" ) &amp;&amp; sleep 0'"'"''
&lt;192.168.80.129&gt; PUT /tmp/tmp3Bk56k TO /home/ansible/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686/setup
&lt;192.168.80.129&gt; SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/y/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.80.129]'
&lt;192.168.80.129&gt; ESTABLISH SSH CONNECTION FOR USER: ansible
&lt;192.168.80.129&gt; SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/home/y/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.80.129 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-rmwgnaejatjdbjwnltokljxsdjjlhagx; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686/setup; rm -rf "/home/ansible/.ansible/tmp/ansible-tmp-1466567672.43-71840509019686/" &gt; /dev/null 2&gt;&amp;1'"'"'"'"'"'"'"'"' &amp;&amp; sleep 0'"'"''
ok: [192.168.80.129]

TASK [Copy huge file] **********************************************************
task path: /home/y/nfvdv4-single/huge_copy.yml:6
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 124, in run
    res = self._execute()
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 446, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/action/copy.py", line 156, in run
    source_full = self._loader.get_real_file(source_full)
  File "/usr/lib/python2.7/dist-packages/ansible/parsing/dataloader.py", line 334, in get_real_file
    data = f.read()
MemoryError

fatal: [192.168.80.129]: FAILED! =&gt; {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @huge_copy.retry

PLAY RECAP *********************************************************************
192.168.80.129             : ok=1    changed=0    unreachable=0    failed=1  
</code></pre></div>