Comments (10)
Thanks for continuing to suggest new things to try. I've opened #82970 which provides a more explicit error saying the calculated local dest path is a directory and it will fail before attempting to copy the file across. As this happens before the fetch operation it will apply to all connection plugins and not just local
.
from ansible.
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the component bot command.
from ansible.
For now, i will mitigate the issue by simply disabling checksum checks with validate_checksum: false
from ansible.
I was made aware that my dest
call misses a trailing /
. When adding this one, the file gets the correct checksum. The scope of this bug has therefore changed, and it seems that a misleading error message about checksums was created, instead of the actual expected error: dest is an existing directory
. Should i create a new issue for this?
from ansible.
You can just re-title/edit this one if you want...
from ansible.
I am unable to replicate
- hosts: localhost
gather_facts: false
tasks:
- copy:
content: data
dest: /tmp/source.txt
- file:
path: /tmp/target
state: '{{ item }}'
loop:
- absent
- directory
- fetch:
src: /tmp/source.txt
dest: /tmp/target
flat: true
This fails (as expected) with
fatal: [localhost]: FAILED! =>
changed: false
msg: dest is an existing directory, use a trailing slash if you want to fetch src
into that directory
I've tried a few permutations like
- Setting dest to an existing file
- Setting dest to a non-existing path
- Setting dest to an existing and non-existing folder with
/
All of these work as expected and doesn't fail with the error about a checksum. Can you share more about your example so we can potentially try and replicate the error?
from ansible.
This is a possible reproducer (I'm just not too sure it is the same scenario described by stenno):
test.yml
---
- hosts: host
gather_facts: false
tasks:
- fetch:
src: /var/tmp/test_file
dest: /tmp/outdir/
flat: true
TEST 1: All good
% ls -l /tmp/outdir
total 0
% ansible-playbook test.yml
PLAY [host] ************************************************************************************************************************************************************************************************************************************
TASK [fetch] ***********************************************************************************************************************************************************************************************************************************
changed: [host]
PLAY RECAP *************************************************************************************************************************************************************************************************************************************
host : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
% ls -l /tmp/outdir
total 60
-rw-r--r-- 1 user user 57984 Mar 22 11:09 test_file
TEST 2: Checksum mismatch error, file is still transferred to unexpected location
% rm /tmp/outdir/test_file
% mkdir /tmp/outdir/test_file
% ls -l /tmp/outdir
total 0
drwxr-xr-x 2 user user 40 Mar 22 11:10 test_file
% ansible-playbook test.yml
PLAY [host] ************************************************************************************************************************************************************************************************************************************
TASK [fetch] ***********************************************************************************************************************************************************************************************************************************
fatal: [host]: FAILED! => {"changed": false, "checksum": null, "dest": "/tmp/outdir/test_file", "file": "/var/tmp/test_file", "md5sum": null, "msg": "checksum mismatch", "remote_checksum": "c5a9c32c90a910eb717b287d15917fa8e292d81d", "remote_md5sum": null}
PLAY RECAP *************************************************************************************************************************************************************************************************************************************
host : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
% tree /tmp/outdir/
/tmp/outdir/
└── test_file
└── test_file
2 directories, 1 file
from ansible.
Thanks for sharing, I still cannot replicate based on your information. I've tried it where a folder exists in '{{ dest }}/{{ src_filename }}
like in your example but fetch
just seems to remove the directory and place the file there. I can get it to fail if src
is pointed towards a directory as expected but not the checksum mismatch. Can you create a example where hosts: localhost
and the source and target setup is created inside the playbook itself.
from ansible.
- hosts: localhost
gather_facts: false
tasks:
- file:
path: /tmp/test
state: absent
- file:
path: /tmp/test/file
state: directory
- hosts: host
gather_facts: false
tasks:
- copy:
content: test file
dest: /tmp/file
- fetch:
flat: true
src: /tmp/file
dest: /tmp/test/
Does not reproduce when host
is localhost (connection: local), proper expected message is generated:
TASK [fetch] *************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "failed to transfer file to /tmp/test/file: [Errno 21] Is a directory: b'/tmp/test/file'"}
However, when host
is available via ssh connection, this is what we get:
TASK [fetch] *************************************************************************************************
fatal: [host]: FAILED! => {"changed": false, "checksum": null, "dest": "/tmp/test/file", "file": "/tmp/file", "md5sum": null, "msg": "checksum mismatch", "remote_checksum": "8f93542443e98f41fe98e97d6d2a147193b1b005", "remote_md5sum": null}
from ansible.
Thanks, I’ll try again tomorrow connecting over ssh to a host.
from ansible.
Related Issues (20)
- Implement Attribute Specific No Log Parameter HOT 1
- Too many files problem with 1000 forks HOT 2
- group_names var ordered by name instead of level HOT 2
- Updating SLES12 failed HOT 2
- Empty hostname produced from delegate_to, even though task should be skipped HOT 2
- win_owner doesn't work for UNC path HOT 1
- Plugin development documentation requires updates which address handling Unsafe value wrappers HOT 5
- Running with emtpy string as argument to --limit should fail HOT 3
- Single string not cast to list of strings in role argument_spec validation HOT 4
- Allow usage of extra vars in `ansible.builtin.generator` inventory plugin, enabling the dynamic generation of inventory host names at runtime. HOT 1
- fetch checksum with auth HOT 4
- argument_spec: default value for dict entries do not work HOT 9
- Galaxy does not support branch names as version in requirements file HOT 10
- Ansible 2.17 returns code 2 when some hosts are failing and rescued HOT 4
- `meta` tasks break host/fork affinity with `host_pinned` strategy HOT 2
- invalid permissions on postgres pod HOT 3
- win_splitdrive filter returns driveletter with a colon and not only a driveletter HOT 5
- Package ansible-core 2.16 from RHEL 8.10 conflicts with ansible 8.3 from EPEL EL8 during dnf/yum update HOT 3
- Children in host.yml gets conflicting HOT 4
- win_iis_webapppool HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible.