# Failed to transfer file message

**URL:** <https://forum.ansible.com/t/failed-to-transfer-file-message/40790>\
**Category:** Get Help\
**Created:** [March 4, 2025, 9:05pm UTC](https://forum.ansible.com/t/failed-to-transfer-file-message/40790 "2025-03-04T21:05:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpearceFL](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@dpearceFL](https://forum.ansible.com/u/dpearceFL)\
**Post date:** [March 4, 2025, 9:05pm UTC](https://forum.ansible.com/t/failed-to-transfer-file-message/40790/1 "2025-03-04T21:05:34Z")

</div>

Here is my code.

```auto
---
- hosts: localhost
  become: true
  gather_facts: false

  vars:
    key_fn: "~/.ssh/id_rsa"

  tasks:
  - name: Check if file exists
    stat:
      path: "{{ key_fn }}"
    register: result

```

Here is the error I get:

```auto
TASK [Check if file exists] ****************************************************************************************************************************************************************
task path: /home/username/create_keys.yml:10
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: csswx-inf
<127.0.0.1> EXEC /bin/sh -c 'echo ~csswx-inf && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/username/.ansible/tmp `"&& mkdir "` echo /home/username/.ansible/tmp/ansible-tmp-1741121935.9362278-164236-271844918348868 `" && echo ansible-tmp-1741121935.9362278-164236-271844918348868="` echo /home/username/.ansible/tmp/ansible-tmp-1741121935.9362278-164236-271844918348868 `" ) && sleep 0'
Using module file /usr/lib/python3.9/site-packages/ansible/modules/stat.py
<127.0.0.1> PUT /home/username/.ansible/tmp/ansible-local-164232ueu2v7ga/tmp2lhlfh29 TO /home/username/.ansible/tmp/ansible-tmp-1741121935.9362278-164236-271844918348868/AnsiballZ_stat.py
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/username/.ansible/tmp/ansible-tmp-1741121935.9362278-164236-271844918348868/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "msg": "failed to transfer file to /home/username/.ansible/tmp/ansible-tmp-1741121935.9362278-164236-271844918348868/AnsiballZ_stat.py: [Errno 1] Operation not permitted: b'/home/username/.ansible/tmp/ansible-local-164232ueu2v7ga/tmp2lhlfh29'"
}

```

Why? The user “username” has these permissions:

```auto
drwx------. 3 username username 17 Mar 4 20:04 .ansible

```

Thanks.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [March 4, 2025, 9:22pm UTC](https://forum.ansible.com/t/failed-to-transfer-file-message/40790/2 "2025-03-04T21:22:35Z")

</div>

`csswx-inf` != `username` ?

---

<div class="post-metadata">

**Author:** ![dpearceFL](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@dpearceFL](https://forum.ansible.com/u/dpearceFL)\
**Post date:** [March 5, 2025, 1:12pm UTC](https://forum.ansible.com/t/failed-to-transfer-file-message/40790/3 "2025-03-05T13:12:51Z")

</div>

Sorry was trying to anonymize things.

---

<div class="post-metadata">

**Author:** ![dpearceFL](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@dpearceFL](https://forum.ansible.com/u/dpearceFL)\
**Post date:** [March 5, 2025, 1:17pm UTC](https://forum.ansible.com/t/failed-to-transfer-file-message/40790/4 "2025-03-05T13:17:42Z")

</div>

Here are the messages for a user called fred.

```auto
TASK [Check if file exists] ****************************************************************************************************************************************************************
task path: /home/fred/create_keys.yml:10
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: fred
<127.0.0.1> EXEC /bin/sh -c 'echo ~fred && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/fred/.ansible/tmp `"&& mkdir "` echo /home/fred/.ansible/tmp/ansible-tmp-1741180412.2887495-167410-17060392045159 `" && echo ansible-tmp-1741180412.2887495-167410-17060392045159="` echo /home/fred/.ansible/tmp/ansible-tmp-1741180412.2887495-167410-17060392045159 `" ) && sleep 0'
Using module file /usr/lib/python3.9/site-packages/ansible/modules/stat.py
<127.0.0.1> PUT /home/fred/.ansible/tmp/ansible-local-167406i299jc83/tmphl14ejvq TO /home/fred/.ansible/tmp/ansible-tmp-1741180412.2887495-167410-17060392045159/AnsiballZ_stat.py
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/fred/.ansible/tmp/ansible-tmp-1741180412.2887495-167410-17060392045159/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "msg": "failed to transfer file to /home/fred/.ansible/tmp/ansible-tmp-1741180412.2887495-167410-17060392045159/AnsiballZ_stat.py: [Errno 1] Operation not permitted: b'/home/fred/.ansible/tmp/ansible-local-167406i299jc83/tmphl14ejvq'"
}

```

I am running this playbook as “fred” without sudo.

Why the failure?

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [March 5, 2025, 2:49pm UTC](https://forum.ansible.com/t/failed-to-transfer-file-message/40790/5 "2025-03-05T14:49:51Z")

</div>

What is the ownership of `/home/fred/.ansible` and `/home/fred/.ansible/tmp`? All I can think of is that either might be `root:root`?
