[Errno 95] Operation not supported in copy module when using destination to CIFS mounted filesystem

Solution Verified - Updated -

Environment

  • Ansible Automation Platform 2.4
  • ansible-core >= 2.14

Issue

  • ansible.builtin.copy module generates error when copying file to CIFS mounted filesystem, enforcing or permissive SELinux mode does not make difference.

Resolution

  • Add the following line to Extra Environment Variables :
AAP WebUI -> Administration -> Settings > Job Settings -> Edit -> Extra Environment Variables

"ANSIBLE_SELINUX_SPECIAL_FS": "cifs"

Root Cause

  • Some filesystems do not support safe operations and/or return inconsistent errors

Diagnostic Steps

1) The task failed but the file has been copied to the destination:

fatal: [HOST]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "cur_context": ["system_u", "object_r", "cifs_t", "s0"], "gid": 0, "group": "root", "input_was": ["system_u", "object_r", "default_t", "s0"], "mode": "0755", "msg": "invalid selinux context: [Errno 95] Operation not supported", "new_context": ["system_u", "object_r", "default_t", "s0"], "owner": "root", "path": "/cifs_share/test3.xlsx", "secontext": "system_u:object_r:cifs_t:s0", "size": 2, "state": "file", "uid": 0}


# ls -lZ /cifs_share/
total 4
-rwxr-xr-x. 1 root root system_u:object_r:cifs_t:s0 2 Sep 20 14:26 test3.xlsx

2) When repeating the task , no errors :

ok: [HOST] => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "checksum": "a3db5c13ff90a36963278c6a39e4ee3c22e2a436", "dest": "/cifs_share/test3.xlsx", "gid": 0, "group": "root", "md5sum": "6d7fce9fee471194aa8b5b6e47267f03", "mode": "0755", "owner": "root", "secontext": "system_u:object_r:cifs_t:s0", "size": 2, "src": "/tmp/test3.xlsx", "state": "file", "uid": 0}

3) Setting secontext on copy task using selevel,serole,setype and seuser did not change the behavior.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments