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:
SesquipedalianDefenestrator 2017-04-28 06:43:51 -07:00 committed by John R Barker
commit 3f321e7591
2 changed files with 37 additions and 2 deletions

View file

@ -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