Debian Codegraph @

test/integration/targets/lookup_url/tasks/use_netrc.yml

raw
1 - name: Write out ~/.netrc
2 copy:
3 dest: "~/.netrc"
4 # writing directly to ~/.netrc because plug-in doesn't support NETRC environment overwrite
5 content: |
6 machine {{ httpbin_host }}
7 login foo
8 password bar
9 mode: "0600"
10
11 - name: test Url lookup with netrc forced Basic auth
12 set_fact:
13 web_data: "{{ lookup('ansible.builtin.url', 'https://' ~ httpbin_host ~ '/basic-auth/foo/bar', headers={'Authorization':'Bearer foobar'}) | from_json }}"
14
15 - name: assert test Url lookup with netrc forced Basic auth
16 assert:
17 that:
18 - web_data.user == 'foo'
19
20 - name: test Url lookup with use_netrc=False
21 set_fact:
22 web_data: "{{ lookup('ansible.builtin.url', 'https://' ~ httpbin_host ~ '/bearer', headers={'Authorization':'Bearer foobar'}, use_netrc='False') | from_json }}"
23
24 - name: assert test Url lookup with netrc=False used Bearer authentication
25 assert:
26 that:
27 - web_data.token == 'foobar'
28
29 - name: Clean up. Removing ~/.netrc
30 file:
31 path: ~/.netrc
32 state: absent