Hi All,

I searched a quite but could able to find what I wanted
Could any pls suggest me how to get the Username in the host machine. In
Linux if I run the below command I get what I suppose to get but don’t know
how to do it ansible. Any code Ansible or python would be helpful

Fin Linux:
*X1234@hostname$*su -
*root@hostname#*who am i
x1234  pts/2   2023-07-29  (vxj-...@domain.com)

My *getuser.yml*:
- debug: {{ lookup(‘env’, ‘USER’) }}
   delegate_to: localhost

- local_action: command whoami
   register: user_name

*root@hostname#* ansible-playbook getuser.yml
Both returning me *root*. I wanted to have *X1234* user instead. I want use
that user ID in my from address in mail module.  Any insight would be
very helpfu.

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEuB3Ao1t7Wi%3DjcoBVezKwUiz_-EyaZ6%2BF_Gjb8EYRK8PusGjg%40mail.gmail.com.

Reply via email to