File: test_unreadable_with_stat.yml

package info (click to toggle)
ansible-core 2.19.0~beta6-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 32,628 kB
  • sloc: python: 180,313; cs: 4,929; sh: 4,601; xml: 34; makefile: 21
file content (36 lines) | stat: -rw-r--r-- 1,113 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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: Check connectivity
      command: whoami
      register: whoami

    - name: Verify user
      assert:
        that:
          - whoami.stdout == 'fetcher'

    - 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')