ansible.builtin.sudo become – Substitute User DO

Note

This become plugin is part of ansible-core and included in all Ansible installations. In most cases, you can use the short plugin name sudo. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.sudo for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same become plugin name.

New in Ansible 2.8

Synopsis

  • This become plugin allows your remote/login user to execute commands as another user via the sudo utility.

Parameters

Parameter

Comments

become_exe

string

Sudo executable

Default: "sudo"

Configuration:

  • INI entries:

    [privilege_escalation]
    become_exe = sudo
    
    [sudo_become_plugin]
    executable = sudo
    
  • Environment variable: ANSIBLE_BECOME_EXE

  • Environment variable: ANSIBLE_SUDO_EXE

  • Keyword: become_exe

  • Variable: ansible_become_exe

  • Variable: ansible_sudo_exe

become_flags

string

Options to pass to sudo

Default: "-H -S -n"

Configuration:

  • INI entries:

    [privilege_escalation]
    become_flags = -H -S -n
    
    [sudo_become_plugin]
    flags = -H -S -n
    
  • Environment variable: ANSIBLE_BECOME_FLAGS

  • Environment variable: ANSIBLE_SUDO_FLAGS

  • Keyword: become_flags

  • Variable: ansible_become_flags

  • Variable: ansible_sudo_flags

become_pass

string

Password to pass to sudo

Configuration:

  • INI entry:

    [sudo_become_plugin]
    password = VALUE
    
  • Environment variable: ANSIBLE_BECOME_PASS

  • Environment variable: ANSIBLE_SUDO_PASS

  • Variable: ansible_become_password

  • Variable: ansible_become_pass

  • Variable: ansible_sudo_pass

become_user

string

User you ‘become’ to execute the task

Default: "root"

Configuration:

  • INI entries:

    [privilege_escalation]
    become_user = root
    
    [sudo_become_plugin]
    user = root
    
  • Environment variable: ANSIBLE_BECOME_USER

  • Environment variable: ANSIBLE_SUDO_USER

  • Keyword: become_user

  • Variable: ansible_become_user

  • Variable: ansible_sudo_user

Note

Configuration entries listed above for each entry type (Ansible variable, environment variable, and so on) have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. The entry types are also ordered by precedence from low to high priority order. For example, an ansible.cfg entry (further up in the list) is overwritten by an Ansible variable (further down in the list).

Authors

  • ansible (@core)