ansible.builtin.su become – Substitute User

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 su even without specifying the collections: keyword. However, we recommend you use the FQCN 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 su utility.

Parameters

Parameter

Comments

become_exe

string

Su executable

Default: "su"

Configuration:

  • INI entries:

    [privilege_escalation]
    become_exe = su
    
    [su_become_plugin]
    executable = su
    
  • Environment variable: ANSIBLE_BECOME_EXE

  • Environment variable: ANSIBLE_SU_EXE

  • Variable: ansible_become_exe

  • Variable: ansible_su_exe

  • Keyword: become_exe

become_flags

string

Options to pass to su

Default: ""

Configuration:

  • INI entries:

    [privilege_escalation]
    become_flags = ""
    
    [su_become_plugin]
    flags = ""
    
  • Environment variable: ANSIBLE_BECOME_FLAGS

  • Environment variable: ANSIBLE_SU_FLAGS

  • Variable: ansible_become_flags

  • Variable: ansible_su_flags

  • Keyword: become_flags

become_pass

string

Password to pass to su

Configuration:

  • INI entry:

    [su_become_plugin]
    password = VALUE
    
  • Environment variable: ANSIBLE_BECOME_PASS

  • Environment variable: ANSIBLE_SU_PASS

  • Variable: ansible_become_password

  • Variable: ansible_become_pass

  • Variable: ansible_su_pass

become_user

string

User you ‘become’ to execute the task

Default: "root"

Configuration:

  • INI entries:

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

  • Environment variable: ANSIBLE_SU_USER

  • Variable: ansible_become_user

  • Variable: ansible_su_user

  • Keyword: become_user

prompt_l10n

list / elements=string

List of localized strings to match for prompt detection

If empty we’ll use the built in one

Do NOT add a colon (:) to your custom entries. Ansible adds a colon at the end of each prompt; if you add another one in your string, your prompt will fail with a “Timeout” error.

Default: []

Configuration:

  • INI entry:

    [su_become_plugin]
    localized_prompts =
    
  • Environment variable: ANSIBLE_SU_PROMPT_L10N

  • Variable: ansible_su_prompt_l10n

Authors

  • ansible (@core)

Hint

Configuration entries for each entry type 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.