ansible/test/integration/targets/fetch/test_unreadable_with_stat.yml
Sam Doran be0cdc0ea2
deprecate _remote_checksum() and remove use in fetch (#74848)
* Remove use of _remote_checksum from fetch module
* Add deprecation message displayed during runtime
* Increase test coverage for fetch
* Add tests covering the use of stat from the fetch module

    This required creating an unpriveleged user account and connecting as that user remotely since
    it is not possible to create a file that the root user cannot stat.

* Use fact caching to persist remote tmp dir across playbook runs
* Add variables to setup_remote_tmp test role to allow caching of the remote temp dir fact
  and preventing removal of the remote_tmp_dir
2021-06-16 13:51:07 -04:00

27 lines
944 B
YAML

# This playbook needs to be run as a non-root user without become. Under
# those circumstances, the fetch module uses stat and not slurp.
- name: Test unreadable file using stat
hosts: testhost
gather_facts: no
tasks:
- name: Try to fetch a file inside an inaccessible directory
fetch:
src: "{{ remote_tmp_dir }}/noaccess/file1"
dest: "{{ output_dir }}"
register: failed_fetch_no_access
ignore_errors: yes
- name: Try to fetch a file inside an inaccessible directory without fail_on_missing
fetch:
src: "{{ remote_tmp_dir }}/noaccess/file1"
dest: "{{ output_dir }}"
fail_on_missing: no
register: failed_fetch_no_access_fail_on_missing
- assert:
that:
- failed_fetch_no_access is failed
- failed_fetch_no_access.msg is search('Permission denied')
- failed_fetch_no_access_fail_on_missing.msg is search(', ignored')