# Ansible Copy module error - "Exec format error"

**URL:** <https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804>\
**Category:** Ansible Project\
**Created:** [June 22, 2017, 2:51pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804 "2017-06-22T14:51:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [June 22, 2017, 2:51pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/1 "2017-06-22T14:51:48Z")

</div>

I get the error below when trying to copy a directory (from local to local)

Anyone know why? (It doesn’t work either with trailing slashes in src and destination, also destination does exist)

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [June 22, 2017, 3:01pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/2 "2017-06-22T15:01:21Z")

</div>

Resolved this when I set gather\_facts: no. Anyone know why that would be? ansible 2.3.0.0

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 22, 2017, 3:04pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/3 "2017-06-22T15:04:45Z")

</div>

file is executable, fact gathering will try to execute, but it does  
not seem to be a proper executable.

a) fix file permissions (assuming its JSON data) b) fix file to  
execute properly

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [June 22, 2017, 3:15pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/4 "2017-06-22T15:15:04Z")

</div>

I dont follow. Its not a file though, its a directory. Both are directories…

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [June 22, 2017, 3:23pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/5 "2017-06-22T15:23:04Z")

</div>

The src directory is executable

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [June 22, 2017, 4:34pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/6 "2017-06-22T16:34:39Z")

</div>

Brian wrote about the error messages.

fatal: [127.0.0.1]: FAILED! =\> {"changed": false, "cmd":  
"/etc/ansible/facts.d/stuff.fact", "failed": true, "msg": "[Errno 8] Exec format error", "rc": 8}

The file "/etc/ansible/facts.d/stuff.fact" has the execution bit set but is not a valid script.  
When does files has the execution bit set Ansible will try to execute them. Remove the bit and Ansible will read the content.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 22, 2017, 5:40pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/7 "2017-06-22T17:40:31Z")

</div>

Sorry, I should have been more specific, the copy task has nothing to  
do with the error, it is all about the fact gathering (setup task)  
that happens before it. That is what gives you the error and the  
problem is this file /etc/ansible/facts.d/stuff.fact, which I  
explained how to solve in the previous email.

---

<div class="post-metadata">

**Author:** ![Anfield](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Anfield](https://forum.ansible.com/u/Anfield)\
**Post date:** [June 22, 2017, 7:11pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/8 "2017-06-22T19:11:13Z")

</div>

Ok. Thanks. Once I update the stuff.fact file then the playbook runs fine.

---

<div class="post-metadata">

**Author:** ![Larry\_Bakun](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@Larry\_Bakun](https://forum.ansible.com/u/Larry_Bakun)\
**Post date:** [January 17, 2018, 5:30pm UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/9 "2018-01-17T17:30:11Z")

</div>

Can you please share your solution? I’m facing the same issue.

---

<div class="post-metadata">

**Author:** ![riturajb](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@riturajb](https://forum.ansible.com/u/riturajb)\
**Post date:** [January 31, 2018, 8:39am UTC](https://forum.ansible.com/t/ansible-copy-module-error-exec-format-error/24804/10 "2018-01-31T08:39:44Z")

</div>

I am facing same error although using a command module - in the with\_items.  
snippet below.

I turned off gathering of facts. I do not see any file related to facts on Ubuntu 16.04 /etc/ansible. Please let me know what is the fix/workaround.

- name: Install SSL  
command: chdir=“/usr/local/downloads/openssl-1.0.2f” {{item}}  
with\_items:
- “./Configure linux-x86\_64 --prefix=/usr”
- “make”
- “make install”

Error : failed: [localhost] (item=./Configure linux-x86\_64 --prefix=/usr) =\> {“cmd”: “./Configure linux-x86\_64 --prefix=/usr”, “failed”: true, “item”: “./Configure linux-x86\_64 --prefix=/usr”, “msg”: “[Errno 8] Exec format error”, “rc”: 8}

The command works outside of ansible.
