mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Add check_mode to get_url (#20532)
* Add check_mode to get_url that does a HEAD request to make sure the URL exists, but doesn't write the real file
* Add info about new --check behavior to docs. Add tests for the new behavior. Populate res_args with the info the tests are looking for.
* Add trailing comma
* Change nonexistent test URL to http://{{httpbin_host}/DOESNOTEXIST. Fix spacing while I'm at it
* Further spacing cleanup
* State that this functionality is in Ansible 2.4+
This commit is contained in:
committed by
John R Barker
parent
ca7616b4a1
commit
3f321e7591
@@ -65,6 +65,28 @@
|
||||
that:
|
||||
- result.failed
|
||||
|
||||
- name: test HTTP HEAD request for file in check mode
|
||||
get_url: url="http://{{ httpbin_host }}/get" dest={{ output_dir }}/get_url_check.txt force=yes
|
||||
check_mode: True
|
||||
register: result
|
||||
|
||||
- name: assert that the HEAD request was successful in check mode
|
||||
assert:
|
||||
that:
|
||||
- result.changed
|
||||
- '"OK" in result.msg'
|
||||
|
||||
- name: test HTTP HEAD for nonexistent URL in check mode
|
||||
get_url: url="http://{{ httpbin_host }}/DOESNOTEXIST" dest={{ output_dir }}/shouldnotexist.html force=yes
|
||||
check_mode: True
|
||||
register: result
|
||||
ignore_errors: True
|
||||
|
||||
- name: assert that HEAD request for nonexistent URL failed
|
||||
assert:
|
||||
that:
|
||||
- result.failed
|
||||
|
||||
- name: test https fetch
|
||||
get_url: url="https://{{ httpbin_host }}/get" dest={{output_dir}}/get_url.txt force=yes
|
||||
register: result
|
||||
|
||||
Reference in New Issue
Block a user