Giter Club home page Giter Club logo

Comments (10)

jborean93 avatar jborean93 commented on May 24, 2024 2

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.

ansibot avatar ansibot commented on May 24, 2024

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.

stenno avatar stenno commented on May 24, 2024

For now, i will mitigate the issue by simply disabling checksum checks with validate_checksum: false

from ansible.

stenno avatar stenno commented on May 24, 2024

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.

nitzmahone avatar nitzmahone commented on May 24, 2024

You can just re-title/edit this one if you want...

from ansible.

jborean93 avatar jborean93 commented on May 24, 2024

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.

allixx avatar allixx commented on May 24, 2024

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.

jborean93 avatar jborean93 commented on May 24, 2024

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.

allixx avatar allixx commented on May 24, 2024
- 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.

jborean93 avatar jborean93 commented on May 24, 2024

Thanks, I’ll try again tomorrow connecting over ssh to a host.

from ansible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.