# How to set different oralce\_homes in ansible

**URL:** <https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816>\
**Category:** Ansible Project\
**Created:** [June 18, 2018, 6:26pm UTC](https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816 "2018-06-18T18:26:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swapna\_N](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Swapna\_N](https://forum.ansible.com/u/Swapna_N)\
**Post date:** [June 18, 2018, 6:26pm UTC](https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816/1 "2018-06-18T18:26:37Z")

</div>

. I have different oralce\_home like 11.2.0 and 12.1.0 how to specify different oracle\_home using ansible script. Please suggest me .As you can see default in roles it takes that values…

---

<div class="post-metadata">

**Author:** ![Swapna\_N](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Swapna\_N](https://forum.ansible.com/u/Swapna_N)\
**Post date:** [June 18, 2018, 6:28pm UTC](https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816/2 "2018-06-18T18:28:34Z")

</div>



---

<div class="post-metadata">

**Author:** ![Benny\_Kusman](https://avatars.discourse-cdn.com/v4/letter/b/4da419/32.png) [@Benny\_Kusman](https://forum.ansible.com/u/Benny_Kusman)\
**Post date:** [June 19, 2018, 4:08am UTC](https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816/3 "2018-06-19T04:08:02Z")

</div>

you can use “environment” at the end of playbook

tasks:  
…  
…  
handlers:  
…  
…

environment:  
INSTALL\_DIR: /opt/edge

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 19, 2018, 10:11am UTC](https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816/4 "2018-06-19T10:11:56Z")

</div>

Or you can use group\_vars to set different environment variables

For what its worth I found I had set the following to get sqlplus working

LD\_LIBRARY\_PATH  
ORACLE\_BASE  
TNS\_ADMIN  
PATH  
ORACLE\_HOME  
NLS\_DATE\_FORMAT

---

<div class="post-metadata">

**Author:** ![Swapna\_N](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Swapna\_N](https://forum.ansible.com/u/Swapna_N)\
**Post date:** [June 19, 2018, 12:43pm UTC](https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816/5 "2018-06-19T12:43:26Z")

</div>

what am here doing is automating db tasks after ospatch apply . we have different version of database homes are there. Am using roles to write ansible script.

Here i have written like this.

roles  
– binaries\_relink  
– defaults  
main.yml

oracle\_home: /oracle/product/12.1.0  
oracle\_base: /oracle  
tns\_admin: “{{ oracle\_home }}/network/admin”

am setting like this

In tasks  
main.yml am giving what need to be done.

Here in defaults which oracle\_home i specifiy it takes that only . suppose i want to add 11g home also like oracle\_home=/oracle/product/11.2.0 so how to do this…

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 19, 2018, 1:18pm UTC](https://forum.ansible.com/t/how-to-set-different-oralce-homes-in-ansible/27816/6 "2018-06-19T13:18:34Z")

</div>

See the examples here for how you can set environment:

[https://docs.ansible.com/ansible/devel/user\_guide/playbooks\_environment.html](https://docs.ansible.com/ansible/devel/user_guide/playbooks_environment.html)
