containers / ansible-podman-collections

Repository for Ansible content that can include playbooks, roles, modules, and plugins for use with the Podman tool
GNU General Public License v3.0
271 stars 148 forks source link

Hard coded CLI flags break containers.podman.podman_unshare support for become_method #588

Open Gaibhne opened 1 year ago

Gaibhne commented 1 year ago

Despite become_method being mentioned in the documentation and evaluated when set, containers.podman.podman_unshare is unable to function with any value for become_method other than sudo, due to forcibly injecting sudo-specific CLI parameters without respect for the become method select (so even if you use su, you will still get sudo parameters appended to the attempted call leading to an error.

The culprit is in https://github.com/containers/ansible-podman-collections/blob/181de1463355118385ebc3fcb8f305ca404bc94d/plugins/become/podman_unshare.py#L135-L137 where the CLI parameters are added despite checking the become method a line earlier; I would think they should be added conditionally (and ideally, become_flags should be respected at that point as well). I'm not sure why become_exe is documented and used at all, it seems sudo is the only possible value that can run without error.

The current code makes it completely impossible to use containers.podman.podman_unshare with a loginless account, the forced injection of -i even prevents you from manually appending -s because -i and -s are mutually exclusive.

sshnaidm commented 1 year ago

@Gaibhne can you please attach task that illustrates this use case and the desired outcome? Thanks