Skip to content
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

Allow remote execution become any user. #10236

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

vhsantos
Copy link

@vhsantos vhsantos commented Jul 4, 2024

This PR fix the sudoers.d/user_name configuration to allow the user to run playbooks with others users than root, for example:

- name: Simple playbook demonstrating become and become_user
  hosts: all

  tasks:
    - name: Create a file as the root user (works well)
      ansible.builtin.file:
        path: /tmp/root_file.txt
        state: touch
      become: true
      become_user: root

    - name: Create a file as a different user (dont works, because the users is other than root)
      ansible.builtin.file:
        path: /tmp/www_data_file.txt
        state: touch
      become: true
      become_user: www-data

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be a little wary of changing the long established default for everyone. How about instead of hardcoding it to root (or ALL), we would set it to a result of something like this

host_param('remote_execution_deploy_effective_user') || host_param('remote_execution_effective_user') || 'root'

so that the old behaviour stays, but can be overridden by a, possibly global, parameter?

@ekohl
Copy link
Member

ekohl commented Aug 15, 2024

I'm not sure that's a big deal. If you can become root, you can then run things as any user anyway. Security wise I don't think there's a difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants