You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/module_utils/module_utils_basic_setcwd.yml

29 lines
1.1 KiB
YAML

- hosts: testhost
gather_facts: no
tasks:
- name: make sure the nobody user is available
include_role:
name: setup_nobody
- name: verify AnsibleModule works when cwd is missing
test_cwd_missing:
register: missing
- name: verify AnsibleModule works when cwd is unreadable
test_cwd_unreadable:
register: unreadable
become: yes
become_user: nobody # root can read cwd regardless of permissions, so a non-root user is required here
- name: get real path of home directory of the unprivileged user
raw: "{{ ansible_python_interpreter }} -c 'import os.path; print(os.path.realpath(os.path.expanduser(\"~\")))'"
register: home
become: yes
become_user: nobody
- name: verify AnsibleModule was able to adjust cwd as expected
assert:
that:
- missing.before != missing.after
- unreadable.before != unreadable.after or unreadable.before == '/' or unreadable.before == home.stdout.strip() # allow / and $HOME fallback on macOS when using an unprivileged user