# Want be able to source ~/.profile

**URL:** <https://forum.ansible.com/t/want-be-able-to-source-profile/28773>\
**Category:** Ansible Project\
**Created:** [October 12, 2018, 7:27am UTC](https://forum.ansible.com/t/want-be-able-to-source-profile/28773 "2018-10-12T07:27:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranay\_varankar](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@pranay\_varankar](https://forum.ansible.com/u/pranay_varankar)\
**Post date:** [October 12, 2018, 7:27am UTC](https://forum.ansible.com/t/want-be-able-to-source-profile/28773/1 "2018-10-12T07:27:47Z")

</div>

Hi,

I have added some export task in ~/.profile file & its added but not able to source ~/.profile in remote host.

FYI

- name: Set .profile  
lineinfile:  
path: /root/.profile  
line: export PROMPT\_COMMAND=‘history -a \>(logger -t “cmdlog[$USER:$PWD] $SSH\_CLIENT”)’  
tags:

- PROMPT\_CMD

- name: source .profile  
shell: source /root/.profile  
args:  
executable: /bin/bash  
tags:

- PROMPT\_CMD

---

<div class="post-metadata">

**Author:** ![pranay\_varankar](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@pranay\_varankar](https://forum.ansible.com/u/pranay_varankar)\
**Post date:** [October 12, 2018, 1:49pm UTC](https://forum.ansible.com/t/want-be-able-to-source-profile/28773/2 "2018-10-12T13:49:15Z")

</div>

Hi,

Any update on this?

---

<div class="post-metadata">

**Author:** ![erichymowitz](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@erichymowitz](https://forum.ansible.com/u/erichymowitz)\
**Post date:** [October 12, 2018, 2:47pm UTC](https://forum.ansible.com/t/want-be-able-to-source-profile/28773/3 "2018-10-12T14:47:05Z")

</div>

Each task inside your play is run though a completely separate SSH connection. Sourcing your .profile in one task will have no effect on other tasks.

You can verify this with the -vvv flag.

–EbH

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 12, 2018, 2:49pm UTC](https://forum.ansible.com/t/want-be-able-to-source-profile/28773/4 "2018-10-12T14:49:44Z")

</div>

Looks like you're trying to set some environment variable in one task,  
and trying to use that in another task.  
That won't work. You should define such variables in each task:  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_environment.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html)

Dick

---

<div class="post-metadata">

**Author:** ![aakanksha.jain](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@aakanksha.jain](https://forum.ansible.com/u/aakanksha.jain)\
**Post date:** [October 18, 2018, 8:45am UTC](https://forum.ansible.com/t/want-be-able-to-source-profile/28773/5 "2018-10-18T08:45:40Z")

</div>

I think this code is useful for you ,try it.

**- name: “create java.sh file with permissions.”**  
**file:**  
**path: “/etc/profile.d/java.sh”**  
**state: touch**  
**mode: 0755**

**- name: “create java.sh file with content”**  
**copy:**  
**dest: “/etc/profile.d/java.sh”**  
**content: |**  
**export JRE\_HOME={{ destination\_folder }}java/jre**  
**export PATH=$PATH:$JRE\_HOME/bin**  
**export JAVA\_HOME={{ destination\_folder }}java**  
**export JAVA\_PATH=$JAVA\_HOME**  
**export PATH=$PATH:$JAVA\_HOME/bin**  
**export JBOSS\_HOME={{ destination\_folder }}adobe/adobe\_experience\_manager\_Forms/jboss**  
**export PATH=$PATH:$JBOSS\_HOME/bin/init.d**  
**ignore\_error: true**

**- shell: “source /etc/profile.d/java.sh”**  
**name: “Configure Java by java.sh”**
