Using
become_user
without become
4 tasks:
5 - name: change to postgres user
6 ansible.builtin.command: whoami
7 become_user: postgres 8 changed_when: false
9
10 - name: run yum update
Description
become_user
without become: yes
will not actually change user.
When become
is set to yes
but become_user
is not set, user root
is set.
Bad practice
- name: Run a command as the apache user
command: somecommand
become_user: apache
Recommended
- name: Run a command as the apache user
command: somecommand
become: yes
become_user: apache