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

Add support to urls util for special characters in proxy username and password #47346

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
4 participants
@rafis

rafis commented Oct 19, 2018

SUMMARY

When using any module which uses ansible.module_utils.urls and your username or password for proxy contain special characters like '#' you will get the following error:

fatal: [some_machine]: FAILED! => {"changed": false, "msg": "Connection to proxy failed"}

More detailed error log reveals that error happened in ansible.module_utils.urls:

The full traceback is:
  File "/tmp/ansible_jg073rku/ansible_modlib.zip/ansible/module_utils/urls.py", line 1058, in fetch_url
    client_key=client_key, cookies=cookies)
  File "/tmp/ansible_jg073rku/ansible_modlib.zip/ansible/module_utils/urls.py", line 961, in open_url
    r = urllib_request.urlopen(*urlopen_args)
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 524, in open
    req = meth(req)
  File "/tmp/ansible_jg073rku/ansible_modlib.zip/ansible/module_utils/urls.py", line 753, in http_request
    self.validate_proxy_response(connect_result)
  File "/tmp/ansible_jg073rku/ansible_modlib.zip/ansible/module_utils/urls.py", line 676, in validate_proxy_response
    raise ProxyError('Connection to proxy failed')

fatal: [some_machine]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "data": null,
            "file": null,
            "id": null,
            "key": null,
            "keyring": null,
            "keyserver": null,
            "state": "present",
            "url": "https://pkg.jenkins.io/debian-stable/jenkins.io.key",
            "validate_certs": true
        }
    },
    "msg": "Connection to proxy failed"
}

In my case it was authentication error, because base64 encoded credentials were wrong.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ansible.module_utils.urls

ANSIBLE VERSION
ansible 2.6.5
  config file = /home/user/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.5 (default, Apr  1 2018, 05:46:30) [GCC 7.3.0]
ADDITIONAL INFORMATION

For example, apt_key module uses ansible.module_utils.urls to download key file. Note the "%23" special character here.

- name: Add Jenkins apt repository key.
  environment:
    http_proxy: "http://SA0001user:password%23SpecialCharacter@proxy.corporation.com:3128"
  apt_key:
    url: "https://pkg.jenkins.io/debian-stable/jenkins.io.key"
    state: present

Before

fatal: [some_machine]: FAILED! => {"changed": false, "msg": "Connection to proxy failed"}

After

changed: [some_machine]
@ansibot

This comment has been minimized.

Contributor

ansibot commented Oct 19, 2018

Hi @rafis, thank you for submitting this pull-request!

click here for bot help

@rafis rafis force-pushed the rafis:devel branch from 7cbe7ea to 48fd2ad Oct 22, 2018

@rafis rafis closed this Oct 22, 2018

@rafis rafis reopened this Oct 22, 2018

@rafis

This comment has been minimized.

rafis commented Oct 22, 2018

I made rebase to latest devel, how to trigger CI processing again?

1 similar comment
@rafis

This comment has been minimized.

rafis commented Oct 22, 2018

I made rebase to latest devel, how to trigger CI processing again?

@rafis

This comment has been minimized.

rafis commented Oct 22, 2018

I have made rebase latest devel, how to trigger CI processing again?

@rafis

This comment has been minimized.

rafis commented Oct 22, 2018

I have made rebase to latest devel, how to trigger CI processing again?

@ansibot ansibot added the stale_ci label Oct 30, 2018

@mattclay

This comment has been minimized.

Member

mattclay commented Nov 5, 2018

@rafis Tests run automatically in CI each time you push new commits to your PR.

@mattclay

This comment has been minimized.

Member

mattclay commented Nov 5, 2018

CI is failing because ansible.module_utils.six.moves.urllib.parse.unquote does not exist.

@mattclay mattclay added the ci_verified label Nov 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment