mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
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 <info@aminvakil.com> Reviewed-by: Sumit Jaiswal <sjaiswal@redhat.com> |
||
|---|---|---|
| .. | ||
| .keep | ||
| 1.2.0.yml | ||
| 4_update_readme.yml | ||
| 5_enable_tests.yml | ||
| 6_test_devel.yml | ||
| 7_env.yml | ||
| 11-action-plugins-use-fqcn.yml | ||
| 12_migrate_cgroup_perf_recap_graph.yml | ||
| 14_mount_option.yml | ||
| 15_profile_tasks.yml | ||
| 17_authorized_keys.yml | ||
| 19_enable_tags.yml | ||
| 21-mount-module_util-routing-issue.yml | ||
| 23-selinux-doesnt-create-missing-config-keys.yml | ||
| 25_ansible_metadata.yml | ||
| 26_profile_tasks_doc.yml | ||
| 27_update_examples.yml | ||
| 33_mount.yml | ||
| 35_disable_tests.yml | ||
| 37-authorized_keys-inconsistent-check-mode-values.yml | ||
| 39_remove_license.yml | ||
| 43_remove_shippable.yml | ||
| 74_synchronize_docker.yml | ||
| 82-private-key-override-fix.yml | ||
| 99-at_add_aix_support.yml | ||
| 101-sysctl-dont-persist-when-invalid.yml | ||
| 118-synchronize_bugfix.yml | ||
| 120-synchronize_add_option.yml | ||
| 124_acl.yml | ||
| 126_mount_not_returning_backup_file.yml | ||
| 134_authorized_key.yml | ||
| 144_add_community_docker_connection_plugin_alias.yml | ||
| 156-fix_no-log-needed_false_positives.yml | ||
| 159-fix-60-deprecated-ansible_ssh_user.yml | ||
| 167-synchronize-add_delay_option.yml | ||
| 169_add_lineseparator_to_command.yml | ||
| 175_synchronize.yml | ||
| 179_firewalld.yml | ||
| 181-update_codecov_sh_url.yml | ||
| 185_mount_at_boot.yml | ||
| 187-fix-synchronize-become-user.yml | ||
| 193_firewalld.yml | ||
| 196_boot_opt_for_linux.yml | ||
| 203_boot_opt_for_bsd.yml | ||
| 204_csh_shell.yml | ||
| 207-mount_tests.yml | ||
| 217-restructure_authrized_key_test.yml | ||
| 65931-json-callback-non-lockstep-output.yml | ||
| firewalld_migration.yml | ||
| firewalld_zone_target.yml | ||
| initial_commit.yaml | ||
| misc_fix.yml | ||
| sanity_test_ignore_file.yml | ||
| skippy_deprecation.yml | ||
| synchronize.yml | ||
| test_matrix.yml | ||