When i execute the command "who am i" using ansible's shell module, i get an empty response, i can't figure out why ?
hosts: server1
remote_user: devops
become: true
tasks:
- name: print current user
shell: who am i
register: userr
- debug:
msg: "{{ userr.stdout }}"
[root@ansible test]# ansible-playbook test.yml
PLAY [test playbook] ********************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************
ok: [server1]
TASK [print current user] ***************************************************************************************************************************
changed: [server1]
TASK [debug] ****************************************************************************************************************************************
ok: [server1] => {
"msg": ""
}
PLAY RECAP ******************************************************************************************************************************************
server1 : ok=3 changed=1 unreachable=0 failed=0
shellmodule a lot as I find it more flexible thancommand.