From 65a96daaf40920c9fa1c8da10203f6a1cbe91ac7 Mon Sep 17 00:00:00 2001 From: John HU Date: Tue, 29 Aug 2023 14:27:09 -0700 Subject: [PATCH] Fix typos in url lookup plugin options (#81587) --- .../fragments/fix-url-lookup-plugin-docs.yml | 2 ++ lib/ansible/plugins/lookup/url.py | 6 ++--- .../targets/lookup_url/tasks/main.yml | 24 +++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/fix-url-lookup-plugin-docs.yml diff --git a/changelogs/fragments/fix-url-lookup-plugin-docs.yml b/changelogs/fragments/fix-url-lookup-plugin-docs.yml new file mode 100644 index 00000000000..74cdbc618e9 --- /dev/null +++ b/changelogs/fragments/fix-url-lookup-plugin-docs.yml @@ -0,0 +1,2 @@ +bugfixes: + - lookup/url.py - Fix incorrect var/env/ini entry for `force_basic_auth` diff --git a/lib/ansible/plugins/lookup/url.py b/lib/ansible/plugins/lookup/url.py index e8a8168f1d9..f5c93f28ad9 100644 --- a/lib/ansible/plugins/lookup/url.py +++ b/lib/ansible/plugins/lookup/url.py @@ -81,12 +81,12 @@ options: version_added: "2.10" default: False vars: - - name: ansible_lookup_url_agent + - name: ansible_lookup_url_force_basic_auth env: - - name: ANSIBLE_LOOKUP_URL_AGENT + - name: ANSIBLE_LOOKUP_URL_FORCE_BASIC_AUTH ini: - section: url_lookup - key: agent + key: force_basic_auth follow_redirects: description: String of urllib2, all/yes, safe, none to determine how redirects are followed, see RedirectHandlerFactory for more information type: string diff --git a/test/integration/targets/lookup_url/tasks/main.yml b/test/integration/targets/lookup_url/tasks/main.yml index a7c3dd6a481..83fd5db6d71 100644 --- a/test/integration/targets/lookup_url/tasks/main.yml +++ b/test/integration/targets/lookup_url/tasks/main.yml @@ -52,3 +52,27 @@ - name: Test use_netrc=False import_tasks: use_netrc.yml + +- vars: + ansible_lookup_url_agent: ansible-test-lookup-url-agent + block: + - name: Test user agent + set_fact: + web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/user-agent') }}" + + - name: Assert that user agent is set + assert: + that: + - ansible_lookup_url_agent in web_data['user-agent'] + +- vars: + ansible_lookup_url_force_basic_auth: yes + block: + - name: Test force basic auth + set_fact: + web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/headers', username='abc') }}" + + - name: Assert that Authorization header is set + assert: + that: + - "'Authorization' in web_data.headers"