# ansible playbook permisson error when running command ". oraenv"

**URL:** <https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875>\
**Category:** Ansible Project\
**Created:** [June 26, 2018, 3:28pm UTC](https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875 "2018-06-26T15:28:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kallu\_Srikanth](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@Kallu\_Srikanth](https://forum.ansible.com/u/Kallu_Srikanth)\
**Post date:** [June 26, 2018, 3:28pm UTC](https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875/1 "2018-06-26T15:28:37Z")

</div>

ansible playbook permission error when running the command “. oraenv”

Here is the code:

# setup new env

- command: “. /usr/local/bin/oraenv”

Here is the error:

TASK [ansible-oracle-patching : command] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [[vmcwy60158.prod.acxiom.net](http://vmcwy60158.prod.acxiom.net)]: FAILED! =\> {“changed”: false, “cmd”: “. /usr/local/bin/oraenv”, “msg”: “[Errno 13] Permission denied”, “rc”: 13}

But I can run other commands with elevated privileges

can anybody help please ?

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 26, 2018, 3:53pm UTC](https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875/2 "2018-06-26T15:53:15Z")

</div>

It looks like you are trying to source that file rather than execute it, presumably in order to set environment variables. That probably won’t work, as the environment variables will not survive the death of the shell you ran.

Re the permissions issue: I’m not sure, but you may be attempting to execute “.” (a directory) and that would get you “permission denied”. Not sure how command works, so that might well be BS 🙂

Regards, K.

---

<div class="post-metadata">

**Author:** ![Kallu\_Srikanth](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@Kallu\_Srikanth](https://forum.ansible.com/u/Kallu_Srikanth)\
**Post date:** [June 26, 2018, 4:35pm UTC](https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875/3 "2018-06-26T16:35:13Z")

</div>

ok forget about the permission error, I am trying to change my environment to ASM environment with this commands

1. ORAENV\_ASK=NO
2. export ORACLE\_SID=+ASM
3. . oraenv

ASK [ansible-oracle-patching : changing to ASM environment] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [[vmcwy60158.prod.acxiom.net](http://vmcwy60158.prod.acxiom.net)] =\> (item=ORAENV\_ASK=NO)  
changed: [[vmcwy60158.prod.acxiom.net](http://vmcwy60158.prod.acxiom.net)] =\> (item=export ORACLE\_SID=+ASM)  
failed: [[vmcwy60158.prod.acxiom.net](http://vmcwy60158.prod.acxiom.net)] (item=. oraenv) =\> {“changed”: true, “cmd”: “. oraenv”, “delta”: “0:00:00.002241”, “end”: “2018-06-26 11:31:10.927354”, “ite m”: “. oraenv”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2018-06-26 11:31:10.925113”, “stderr”: “/bin/sh: line 0: .: oraenv: file not found”, “stderr\_li nes”: [“/bin/sh: line 0: .: oraenv: file not found”], “stdout”: “”, “stdout\_lines”: }

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 26, 2018, 5:02pm UTC](https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875/4 "2018-06-26T17:02:03Z")

</div>

Post your whole playbook; it’s hard to tell what’s actually happening.

I don’t think I can help, but if you post everything maybe someone else can.

Regards, K.

---

<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 26, 2018, 7:22pm UTC](https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875/5 "2018-06-26T19:22:27Z")

</div>

You need to specify any environment variables using the ‘environment’ keyword on your command.

see [https://docs.ansible.com/ansible/latest/reference\_appendices/faq.html#how-can-i-set-the-path-or-any-other-environment-variable-for-a-task-or-entire-playbook](https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-can-i-set-the-path-or-any-other-environment-variable-for-a-task-or-entire-playbook)

In my experience it can be fiddly getting environment set correctly for commands so that you can run things such as sqlplus, which needed several environment variables to be set before it would work.

I wound up setting something like this in my group\_vars:

oracle\_environment:  
LD\_LIBRARY\_PATH: ‘/opt/app/oracle/product/db11gR2\_1/lib’  
ORACLE\_BASE: ‘/opt/app/oracle’  
TNS\_ADMIN: ‘/opt/app/oracle/common/network/admin’  
PATH: “{{ ansible\_env.PATH}}:/opt/app/oracle/product/db11gR2\_1/bin:/usr/local/bin:/bin:/usr/bin:.:/sbin”  
ORACLE\_HOME: ‘/opt/app/oracle/product/db11gR2\_1’  
NLS\_DATE\_FORMAT: ‘DD-MON-YYYY HH24:MI:SS’

and then using something like the following to run sqlplus.

- name: test sqlplus  
shell: sqlplus -L {{ oracle\_user }}/{{ oracle\_cred }}@{{ oracle\_host }}/{{ oracle\_tns }} @TESTS/Ensure\_Connection.sql  
args:  
chdir: database\_scripts  
executable: /bin/bash  
environment: “{{ oracle\_environment }}”  
register: sqlplus\_result

- name: show sqlplus result  
debug:  
var: sqlplus\_result

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Kallu\_Srikanth](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@Kallu\_Srikanth](https://forum.ansible.com/u/Kallu_Srikanth)\
**Post date:** [June 27, 2018, 1:52am UTC](https://forum.ansible.com/t/ansible-playbook-permisson-error-when-running-command-oraenv/27875/6 "2018-06-27T01:52:38Z")

</div>

Thank you very much Jon. That helped.
