diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index dd1981f3843..9bcba7fbe99 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -671,8 +671,18 @@ class ActionBase(ABC, _AnsiblePluginInfoMixin): become_user, setfacl_mode) - if res['rc'] == 0: - return remote_paths + match res.get('rc'): + case 0: + return remote_paths + case 2: + # invalid syntax (for example, missing user, missing colon) + self._display.debug(f"setfacl command failed with an invalid syntax. Trying chmod instead. Err: {res!r}") + case 127: + # setfacl binary does not exists or we don't have permission to use it. + self._display.debug(f"setfacl binary does not exist or does not have permission to use it. Trying chmod instead. Err: {res!r}") + case _: + # generic debug message + self._display.debug(f'Failed to set facl {setfacl_mode}, got:{res!r}') # Step 3b: Set execute if we need to. We do this before anything else # because some of the methods below might work but not let us set