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

Give open_url the same default user-agent as fetch_url #56635

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
4 participants
@mjrider
Copy link

commented May 20, 2019

after debugging de difference between get_url and lookup('url' the difference seems to be the User-Agent.
This sync's the user-agent in both function

SUMMARY

While automating the configuration of our loadbalancer with an ip whitelist of cloudflare. had an issue that get_url could fetch the list of ip's and lookup('url',..) gave an 403, because cloudflare blocks the default python request user-agent.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

urls

ADDITIONAL INFORMATION

Broken url example:
ansible -mdebug -a"msg={{lookup('url','https://cloudflare.com/ips-v4')}}" localhost

More verbose output doesn't add any information

url lookup connecting to https://cloudflare.com/ips-v4
localhost | FAILED! => {
    "msg": "An unhandled exception occurred while running the lookup plugin 'url'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Received HTTP error for https://cloudflare.com/ips-v4 : HTTP Error 403: Forbidden"
}

Working get_url
ansible -v -m get_url -a "url=https://cloudflare.com/ips-v4 dest=/tmp/foo" localhost

Give open_url the same default user-agent as fetch_url
after debugging de difference between `get_url` and `lookup('url'` the difference seems to be the User-Agent.
This sync's the user-agent in both function
@samdoran

This comment has been minimized.

Copy link
Member

commented May 23, 2019

Please create a changelog fragment. See this fragment as an example.

@sivel
Copy link
Member

left a comment

Please also add a unit test to validate this change.

@ansibot ansibot added the stale_ci label May 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.