-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
synchronize module ignores become_user when become in effect #186
Comments
resolved_by_pr #187 |
It's not merged yet. |
ansible-zuul bot
added a commit
that referenced
this issue
Jul 8, 2021
synchronize: fix to honor become_user when become_method sudo SUMMARY When become_method is sudo, the synchronize module ignores become_user, always running as root. This means one cannot create files as a target user, when they need to get in via a third user and can only sudo via that one. In my case, I'm connecting via a special provisioning user that has sudo privs, but I need to create the files as the become_user. I'm using it to deposit skeleton files, and there should be no reason to run another task with chown; after all, the documentation already describes the desired behavior: The user and permissions for the synchronize dest are those of the remote_user on the destination host or the become_user if become=yes is active. This patch takes the running become_user (if it's not None) and adds it to the sudo command with the -u command line option, so the file gets created correctly. I have tested this and it works. Other become_methods are ignored, but they already were anyways (the code already has a TODO to add other methods, which we don't attempt in this patch) Fixes #186 ISSUE TYPE Bugfix Pull Request COMPONENT NAME synchronize ADDITIONAL INFORMATION See reproduction in #186. This appears to have been in place since ansible/ansible@811a906 Reviewed-by: Amin Vakil <[email protected]> Reviewed-by: Sumit Jaiswal <[email protected]>
1 task
1 task
This was referenced Aug 19, 2022
This was referenced Sep 14, 2022
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SUMMARY
The
synchronize
module always writes files as root ifbecome
is in effect andbecome_method
issudo
, regardless of the specifiedbecome_user
. It should write files as thebecome_user
. This is quite unexpected to write the file with a different user than the one specified, and contradicts the documentation for the module:ISSUE TYPE
COMPONENT NAME
synchronize
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
recent linux on client and server
STEPS TO REPRODUCE
EXPECTED RESULTS
remote file should be owned by
scott:scott
as shown bystat
commandACTUAL RESULTS
The text was updated successfully, but these errors were encountered: