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 'url' parameter should be marked required #6857

Closed
rasputnik opened this issue Apr 4, 2014 · 5 comments
Closed

get_url 'url' parameter should be marked required #6857

rasputnik opened this issue Apr 4, 2014 · 5 comments
Labels
bug This issue/PR relates to a bug. net_tools Net-tools category

Comments

@rasputnik
Copy link
Contributor

Issue Type:

Bug Report

Ansible Version:

:$ ansible --version

       ansible 1.6 (devel f6db60cbce) last updated 2014/04/03 15:50:16 (GMT +100)
Environment:

:$ vagrant ssh mslave1 -c 'cat /etc/redhat-release; python --version'

    CentOS release 6.5 (Final)
    Python 2.6.6
    Connection to 127.0.0.1 closed.
Summary:

I fat finger get_url to have a src= field rather than a url= field.
Rather than a usage error, i got a python stack trace (see below).

Steps To Reproduce:

:$ cat bug.hosts

    mslave1 ansible_ssh_host=10.10.10.101 ansible_ssh_user=vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key

:$ cat bug.yml

    - hosts: mslave1
      sudo: yes
      tasks:
        - get_url:     src=http://downloads.mesosphere.io/master/centos/6/mesos_0.17.0_x86_64.rpm
           dest=/tmp/foo
Expected Results:

Some error along the lines of : get_url is missing a required field "url".

Actual Results:

:$ ansible-playbook -i bug.hosts -vv bug.yml

PLAY [mslave1] ****************************************************************

GATHERING FACTS ***************************************************************
<10.10.10.101> REMOTE_MODULE setup
ok: [mslave1]

TASK: [get_url src=http://downloads.mesosphere.io/master/centos/6/mesos_0.17.0_x86_64.rpm dest=/tmp/foo] ***
<10.10.10.101> REMOTE_MODULE get_url src=http://downloads.mesosphere.io/master/centos/6/mesos_0.17.0_x86_64.rpm dest=/tmp/foo
fatal: [mslave1] => failed to parse: SUDO-SUCCESS-ivyegnykbngswzwjvrsrpxnxbcujcysp
Traceback (most recent call last):
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1396609075.72-267618737653381/get_url", line 1770, in <module>
    main()
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1396609075.72-267618737653381/get_url", line 209, in main
    tmpsrc, info = url_get(module, url, dest, use_proxy, last_mod_time, force)
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1396609075.72-267618737653381/get_url", line 134, in url_get
    rsp, info = fetch_url(module, url, use_proxy=use_proxy, force=force, last_mod_time=last_mod_time)
  File "/home/vagrant/.ansible/tmp/ansible-tmp-1396609075.72-267618737653381/get_url", line 1676, in fetch_url
    parsed = urlparse.urlparse(url)
  File "/usr/lib64/python2.6/urlparse.py", line 132, in urlparse
    tuple = urlsplit(url, scheme, allow_fragments)
  File "/usr/lib64/python2.6/urlparse.py", line 171, in urlsplit
    i = url.find(':')
AttributeError: 'NoneType' object has no attribute 'find'


FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/sisred/bug.retry

mslave1                    : ok=1    changed=0    unreachable=1    failed=0

:$

@sivel
Copy link
Member

sivel commented Apr 4, 2014

I see 2 things here:

  1. src is not the correct attribute to use for specifying the URL. The correct attribute is url.
  2. For some reason AnsibleModule isn't reporting that src is an invalid attribute.

@rasputnik rasputnik changed the title get_url on centos 6.5 blows up with SUDO_SUCCESS + stack trace get_url missing required 'url' field - throws stack trace rather than prints error Apr 4, 2014
@rasputnik
Copy link
Contributor Author

Thanks, have updated title to reflect pilot error.

@mpdehaan
Copy link
Contributor

mpdehaan commented Apr 4, 2014

@sivel, src is accepted because it supports the common arguments of the file module, of which this is one.

This seems ridiculously easy to fix just by adding "url" to the argument_spec as a required argument.

@mpdehaan mpdehaan changed the title get_url missing required 'url' field - throws stack trace rather than prints error get_url 'url' parameter should be marked required Apr 4, 2014
@mpdehaan mpdehaan added the module label Apr 4, 2014
@sivel
Copy link
Member

sivel commented Apr 4, 2014

Just as a heads up, and I think making url required is a good idea, that a change may need to happen in both, ec2_facts and nexmo which use url_argument_spec and don't require a 'url' attribute to function.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@AlanCoding
Copy link
Member

I hit an error that resulted in

  File "/usr/lib64/python2.6/urlparse.py", line 171, in urlsplit
    i = url.find(':')
AttributeError: 'NoneType' object has no attribute 'find'

I believe that this constitutes some bad error handling, will look into filing an issue.

@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

6 participants