# ansible question

**URL:** <https://forum.ansible.com/t/ansible-question/26482>\
**Category:** Ansible Project\
**Created:** [January 15, 2018, 7:23pm UTC](https://forum.ansible.com/t/ansible-question/26482 "2018-01-15T19:23:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajesh1](https://avatars.discourse-cdn.com/v4/letter/r/22d042/32.png) [@rajesh1](https://forum.ansible.com/u/rajesh1)\
**Post date:** [January 15, 2018, 7:23pm UTC](https://forum.ansible.com/t/ansible-question/26482/1 "2018-01-15T19:23:35Z")

</div>

May be this question is so basic, frustrating me not in any document explains this scenario. advance thanks for your help .

Ansible not loading the become\_user profile . this may look like small issue but i want to run some scripts in become\_user only . (**acutually become\_user not loading its user profiles )**

there is a difference for commands in linux  
when you are in root user:  
su : it will load only /root home directory  
sudo su : it will load only /root home directory  
su - : it will load /home/ directory. // **do we have this option in ansible**

but in ansible : if we do below, it never runs the profile  
become: yes  
become\_user:   
become\_method: sudo

code example:

1. 
* * *

- name: Este setup  
hosts: server  
gather\_facts: no  
become: yes  
become\_user: raju  
become\_method: sudo // with this or without this same result

tasks:

- name: executing script

shell: pwd  
register: out

- debug: var=out

TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [server] =\> {  
“out”: {  
“changed”: true,  
“cmd”: “pwd”,  
“delta”: “0:00:00.003830”,  
“end”: “2018-01-15 13:19:40.438390”,  
“failed”: false,  
“rc”: 0,  
“start”: “2018-01-15 13:19:40.434560”,  
“stderr”: “”,  
“stderr\_lines”: ,  
**“stdout”: “/root”,**  
“stdout\_lines”: [  
“/root”  
]  
}  
}

—versions info

ansible 2.4.1.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

CentOS Linux release 7.4.1708 (Core)

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 16, 2018, 7:03pm UTC](https://forum.ansible.com/t/ansible-question/26482/2 "2018-01-16T19:03:29Z")

</div>

Most shell have to modes, interactive shell (when you log in and get a prompt) and non-interactive shell (when you run a script).

The two modes read different environment and profile files.  
If you login to a server and execute "env" and if you run "ssh \<username\>@\<hostname\> env" you'll see that you get different result.

Ansible by default uses /bin/sh, and when you log in you probably use bash and they will probably differ.

To read more about interactive/non-interactive shell search the archives, read man bash or search the Internet.
