ansible playbook permisson error when running command ". oraenv"

527 views
Skip to first unread message

Kallu Srikanth

unread,
Jun 26, 2018, 11:28:37 AM6/26/18
to Ansible Project
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]: 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 ?

Karl Auer

unread,
Jun 26, 2018, 11:53:26 AM6/26/18
to ansible...@googlegroups.com
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.


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/74f2b870-1fbc-45f0-a8a4-b92b52fef3bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Karl Auer

Email  : ka...@2pisoftware.com
Website: 
http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

Kallu Srikanth

unread,
Jun 26, 2018, 12:35:13 PM6/26/18
to Ansible Project
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] => (item=ORAENV_ASK=NO)
changed: [vmcwy60158.prod.acxiom.net] => (item=export ORACLE_SID=+ASM)
failed: [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": []}



On Tuesday, June 26, 2018 at 10:53:26 AM UTC-5, Karl Auer wrote:
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.

On Wed, Jun 27, 2018 at 1:28 AM, 'Kallu Srikanth' via Ansible Project <ansible...@googlegroups.com> wrote:
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]: 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 ?

--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Karl Auer

unread,
Jun 26, 2018, 1:02:13 PM6/26/18
to ansible...@googlegroups.com
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.


To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1529e791-b9cd-496f-8be7-29ad4f1db067%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

J Hawkesworth

unread,
Jun 26, 2018, 3:22:27 PM6/26/18
to Ansible Project
You need to specify any environment variables using the 'environment' keyword on your command.


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

Kallu Srikanth

unread,
Jun 26, 2018, 9:52:38 PM6/26/18
to Ansible Project
Thank you very much Jon. That helped.
Reply all
Reply to author
Forward
0 new messages