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

get_url with 1.4 against centos6.4 always downloads URL. #5019

Closed
jeremychase opened this issue Nov 22, 2013 · 4 comments
Closed

get_url with 1.4 against centos6.4 always downloads URL. #5019

jeremychase opened this issue Nov 22, 2013 · 4 comments
Labels
bug This issue/PR relates to a bug. net_tools Net-tools category

Comments

@jeremychase
Copy link

The following action will always download the target URL when using Ansible 1.4. It acts as if Force=yes. This test was done with an OSX host against a CentOS6.4 target machine:

The same get_url against a Debian machine does not exhibit this problem.

@jctanner
Copy link
Contributor

@jeremychase from the get_url module docstrings ...

  force:
    description:
      - If C(yes) and C(dest) is not a directory, will download the file every
        time and replace the file if the contents change. If C(no), the file
        will only be downloaded if the destination does not exist. Generally
        should be C(yes) only for small local files. Prior to 0.6, this module
        behaved as if C(yes) was the default.
        Has no effect if C(dest) is a directory - the file will always be
        downloaded, but replaced only if the contents changed.
    version_added: "0.7"
    required: false
    choices: [ "yes", "no" ]
    default: "no"
    aliases: [ "thirsty" ]

Verified behavior with the following playbook ...

- hosts: [el6.lab.net, localhost]
  gather_facts: False
  tasks:
    - get_url: url=http://tannerjc.net/tmp/screenshots/1.png dest=/tmp
      register: result
      with_sequence: count=4
    - debug: var=result

    - get_url: url=http://tannerjc.net/tmp/screenshots/1.png dest=/tmp/destfile.png
      register: result
      with_sequence: count=4
    - debug: var=result

If dest is a directory name, a temporary filename will be generated and the file will be downloaded every time...

            {
                "changed": false, 
                "dest": "/tmp/destfile.png", 
                "gid": 0, 
                "group": "root", 
                "invocation": {
                    "module_args": "url=http://tannerjc.net/tmp/screenshots/1.png dest=/tmp/destfile.png", 
                    "module_name": "get_url"
                }, 
                "item": "3", 
                "mode": "0644", 
                "msg": "file already exists", 
                "owner": "root", 
                "size": 9466, 
                "state": "file", 
                "uid": 0, 
                "url": "http://tannerjc.net/tmp/screenshots/1.png"
            },

If dest is a filename, the url is fetched if the filename does not exist ....

            {
                "changed": false, 
                "dest": "/tmp/destfile.png", 
                "gid": 0, 
                "group": "root", 
                "invocation": {
                    "module_args": "url=http://tannerjc.net/tmp/screenshots/1.png dest=/tmp/destfile.png", 
                    "module_name": "get_url"
                }, 
                "item": "3", 
                "mode": "0644", 
                "msg": "file already exists", 
                "owner": "root", 
                "size": 9466, 
                "state": "file", 
                "uid": 0, 
                "url": "http://tannerjc.net/tmp/screenshots/1.png"
            },

@jeremychase
Copy link
Author

@jctanner Ahh. Sorry for the trouble.

@jctanner
Copy link
Contributor

@jeremychase np, it gave me a chance to review the module.

@paulmaunders
Copy link

This had bugged me for ages! I didn't realise you had to explicitly set the dest filename to ensure it doesn't download it everytime.

jimi-c pushed a commit that referenced this issue Dec 6, 2016
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@dagwieers dagwieers added the net_tools Net-tools category label Mar 3, 2019
@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
bug This issue/PR relates to a bug. net_tools Net-tools category
Projects
None yet
Development

No branches or pull requests

5 participants