--- - hosts: zubt1 tasks: - name: Get current user shell: whoami register: current_user_nobecome - name: Get current user with become is true shell: whoami register: current_user_become become: true - name: Print current user debug: msg: Current user is "{{ current_user_nobecome.stdout }}". Current user with become true is "{{ current_user_become.stdout }}". TASK [Print current user] ******************************************************************************************************************************************* ok: [zubt1] => { "msg": "Current user is \"scnzzh\". Current user with become true is \"root\"." }