From 804a8e637874ffe404b12b3a05305d147168f605 Mon Sep 17 00:00:00 2001 From: jctanner Date: Thu, 21 Apr 2016 16:28:29 -0400 Subject: [PATCH] Fix status check on get_url with file schemas and update the examples. (#3512) Addresses #3511 --- network/basics/get_url.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/network/basics/get_url.py b/network/basics/get_url.py index e762a7c69e6..a100f907b78 100644 --- a/network/basics/get_url.py +++ b/network/basics/get_url.py @@ -178,6 +178,9 @@ EXAMPLES=''' - name: download file with check get_url: url=http://example.com/path/file.conf dest=/etc/foo.conf checksum=sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c get_url: url=http://example.com/path/file.conf dest=/etc/foo.conf checksum=md5:66dffb5228a211e61d6d7ef4a86f5758 + +- name: download file from a file path + get_url: url="file:///tmp/afile.txt" dest=/tmp/afilecopy.txt ''' import urlparse @@ -204,7 +207,7 @@ def url_get(module, url, dest, use_proxy, last_mod_time, force, timeout=10, head module.exit_json(url=url, dest=dest, changed=False, msg=info.get('msg', '')) # create a temporary file and copy content to do checksum-based replacement - if info['status'] != 200: + if info['status'] != 200 and not url.startswith('file:/'): module.fail_json(msg="Request failed", status_code=info['status'], response=info['msg'], url=url, dest=dest) if tmp_dest != '':