Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch module fails on second run if destination directory exists & MD5 sum problem (patches) #450

Closed
jpmens opened this issue Jun 5, 2012 · 3 comments

Comments

@jpmens
Copy link
Contributor

jpmens commented Jun 5, 2012

I have a playbook configured with the following action:

    action: fetch src=/etc/ansible/setup dest=/tmp/ss

On the second ansible run, fetch fails with the following error:

  The error thrown is: OSError: [Errno 17] File exists: '/tmp/ss/k4/etc/ansible'"

I believe the following patch solves the problem:

    *** /tmp/__init__.py    2012-06-05 16:02:08.296101303 +0200
    --- lib/ansible/runner/__init__.py  2012-06-05 15:59:56.346090627 +0200
    ***************
    *** 481,487 ****

              if remote_md5 != local_md5:
                  # create the containing directories, if needed
    !       os.makedirs(os.path.dirname(dest))

                  # fetch the file and check for changes
                  conn.fetch_file(source, dest)
    --- 481,488 ----

              if remote_md5 != local_md5:
                  # create the containing directories, if needed
    !       if os.path.isdir(os.path.dirname(dest)) == False:
    !           os.makedirs(os.path.dirname(dest))

                  # fetch the file and check for changes
                  conn.fetch_file(source, dest)
@jpmens
Copy link
Contributor Author

jpmens commented Jun 5, 2012

On a related note, MD5 sum checking doesn't work for me with the latest version from Git. I'm digging in the dark, but I believe the issue is in the same file as above, a few lines up:

    !         # remote_md5 = self._low_level_exec_command(conn, "md5sum %s" % source, tmp, True)[0].split()[0]
    !         remote_md5 = self._low_level_exec_command(conn, "md5sum %s" % source, tmp, True).split()[0]

The first is the original; remote_md5 contains the first character of the MD5 sum only. The second line fixes that for me. Tested on Ubuntu and RHEL6.2

@phred
Copy link
Contributor

phred commented Jun 5, 2012

Created a pull request: #451

mpdehaan added a commit that referenced this issue Jun 8, 2012
Make 'fetch' test for local directories before creating.  Fixes issue #450
@mpdehaan
Copy link
Contributor

mpdehaan commented Jun 8, 2012

closing since fixed per above merge requests, let me know if that is not the case. Thanks!

@mpdehaan mpdehaan closed this as completed Jun 8, 2012
mpdehaan added a commit that referenced this issue Jul 17, 2012
Make 'fetch' test for local directories before creating.  Fixes issue #450
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants