diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index a08e113a057..0c6a5c31a45 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -359,14 +359,16 @@ class ActionBase(with_metaclass(ABCMeta, object)): # Try to use file system acls to make the files readable for sudo'd # user if execute: - mode = 'r-x' + chmod_mode = 'rx' + setfacl_mode = 'r-x' else: + chmod_mode = 'rX' ### Note: this form fails silently on freebsd. We currently # never call _fixup_perms2() with execute=False but if we # start to we'll have to fix this. - mode = 'r-X' + setfacl_mode = 'r-X' - res = self._remote_set_user_facl(remote_paths, self._play_context.become_user, mode) + res = self._remote_set_user_facl(remote_paths, self._play_context.become_user, setfacl_mode) if res['rc'] != 0: # File system acls failed; let's try to use chown next # Set executable bit first as on some systems an @@ -388,7 +390,7 @@ class ActionBase(with_metaclass(ABCMeta, object)): display.warning('Using world-readable permissions for temporary files Ansible needs to create when becoming an unprivileged user.' ' This may be insecure. For information on securing this, see' ' https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user') - res = self._remote_chmod(remote_paths, 'a+%s' % mode) + res = self._remote_chmod(remote_paths, 'a+%s' % chmod_mode) if res['rc'] != 0: raise AnsibleError('Failed to set file mode on remote files (rc: {0}, err: {1})'.format(res['rc'], to_native(res['stderr']))) else: