Become (Privilege Escalation)

Other topics

Only in a task

- name: Run script as foo user
  command: bash.sh
  become: true
  become_user: foo

Run all role tasks as root

- hosts: all
  become: true

- name: Start apache
  service: apache2
  state: started

Run a role as root

- hosts: all
  roles:
    - { role: myrole, become: yes }
    - myrole2

Syntax:

  • become: can be set to true or yes and triggers the user escalation settings.
  • become_user: set to the desired user in the remote host.
  • become_method: specify the command used to make login and change user.
  • become_flags: change login parameters. Mostly used when you want to change to a system user without shell privileges.

Contributors

Topic Id: 8328

Example Ids: 26726,26727,28879

This site is not affiliated with any of the contributors.