1. <small id='vFj1c'></small><noframes id='vFj1c'>

      2. <tfoot id='vFj1c'></tfoot><legend id='vFj1c'><style id='vFj1c'><dir id='vFj1c'><q id='vFj1c'></q></dir></style></legend>

        • <bdo id='vFj1c'></bdo><ul id='vFj1c'></ul>
        <i id='vFj1c'><tr id='vFj1c'><dt id='vFj1c'><q id='vFj1c'><span id='vFj1c'><b id='vFj1c'><form id='vFj1c'><ins id='vFj1c'></ins><ul id='vFj1c'></ul><sub id='vFj1c'></sub></form><legend id='vFj1c'></legend><bdo id='vFj1c'><pre id='vFj1c'><center id='vFj1c'></center></pre></bdo></b><th id='vFj1c'></th></span></q></dt></tr></i><div id='vFj1c'><tfoot id='vFj1c'></tfoot><dl id='vFj1c'><fieldset id='vFj1c'></fieldset></dl></div>

        尽管在 Ansible 中提升了权限,但仍无法运行脚本

        时间:2023-06-06

            <legend id='Xikgq'><style id='Xikgq'><dir id='Xikgq'><q id='Xikgq'></q></dir></style></legend>

              1. <small id='Xikgq'></small><noframes id='Xikgq'>

              2. <tfoot id='Xikgq'></tfoot>
                  <bdo id='Xikgq'></bdo><ul id='Xikgq'></ul>
                  <i id='Xikgq'><tr id='Xikgq'><dt id='Xikgq'><q id='Xikgq'><span id='Xikgq'><b id='Xikgq'><form id='Xikgq'><ins id='Xikgq'></ins><ul id='Xikgq'></ul><sub id='Xikgq'></sub></form><legend id='Xikgq'></legend><bdo id='Xikgq'><pre id='Xikgq'><center id='Xikgq'></center></pre></bdo></b><th id='Xikgq'></th></span></q></dt></tr></i><div id='Xikgq'><tfoot id='Xikgq'></tfoot><dl id='Xikgq'><fieldset id='Xikgq'></fieldset></dl></div>

                    <tbody id='Xikgq'></tbody>

                • 本文介绍了尽管在 Ansible 中提升了权限,但仍无法运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我尝试在使用 ansible 将它复制到主机上后在主机上运行它.该脚本有 777 个权限.

                  Im trying to run a shell script on the host machine after copying it over there using ansible. The script has 777 permissions.

                  请阅读以下问题,因为它提供了我们正在尝试处理的实际问题的完整范围

                  Please read the below question as it gives the full scope of the actual issue that we are trying to deal with

                  使用 Ansible 设置不同的 ORACLE_HOME 和 PATH 环境变量

                  - name: Run the Script [List]
                    shell: "/tmp/sqlscript/sql_select.sh {{item}} >> /tmp/sqlscript/output.out"
                    become: yes
                    become_method: sudo
                    become_user: oracle
                    register: orh
                    with_items: "{{ factor_dbs.split('\n') }}"
                  

                  下面是shell脚本

                  #!/bin/bash
                  source $HOME/bin/gsd_xenv $1 &> /dev/null
                  
                  sqlplus -s <<EOF
                  / as sysdba
                  set heading off
                  
                  
                  select d.name||','||i.instance_name||','||i.host_name||';' from v\$database d,v\$instance i;
                  
                  EOF
                  

                  尽管提升了权限,但我观察到除非我添加如下环境变量,否则任务不会执行

                  Despite escalating the privileges, I observed that the task is not executing unless I add environment variables like below

                  - name: Run the script [List]
                    shell: "/tmp/sqlscript/oracle_home.sh {{item}} >> /tmp/sqlscript/orahome.out"
                    become: yes
                    become_method: sudo
                    become_user: oracle
                    environment:
                       PATH: "/home/oracle/bin:/usr/orasys/12.1.0.2r10/bin:/usr/bin:/bin:/usr/ucb:/sbin:/usr/sbin:/etc:/usr/local/bin:/oradata/epdmat/goldengate/config/sys"
                       ORACLE_HOME: "/usr/orasys/12.1.0.2r10"
                    register: orh
                    with_items: "{{ factor_dbs.split('\n') }}"
                  

                  然而,这个剧本需要在具有不同路径和 oracle_home 变量的不同主机上运行.

                  However this playbook needs to be run across different hosts which have different path and oracle_home variables.

                  我的问题是,为什么尽管升级了权限,任务仍然运行.当我尝试通过登录服务器并在执行sudo su oracle"后手动运行相同的脚本时,它似乎运行良好.

                  My question is, why doest the task run despite escalating the permissions. When I try to run the same script manually by logging into the server and after doing "sudo su oracle", it seems to be running fine.

                  推荐答案

                  这取决于您实际设置环境变量的位置.在远程机器上登录时执行脚本与通过 ssh 像 Ansible 一样运行脚本是有区别的(参见例如 区分交互式登录和非交互式非登录外壳).根据 shell 的类型和您的系统,加载不同的 bash 配置文件.

                  It depends on where you actually set your environment variables. There is a difference in executing a script when you are logged in at a remote machine, and running a script over ssh as Ansible does (see e.g., Differentiate Interactive login and non-interactive non-login shell). Depending on the type of shell and your system, different bash profiles are loaded.

                  这篇关于尽管在 Ansible 中提升了权限,但仍无法运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 Ansible 设置不同的 ORACLE_HOME 和 PATH 环境变量 下一篇:在 Windows 机器上通过 Ansible 安装 Oracle 客户端 -

                  相关文章

                  最新文章

                  1. <tfoot id='MguM5'></tfoot>

                    <legend id='MguM5'><style id='MguM5'><dir id='MguM5'><q id='MguM5'></q></dir></style></legend>

                    <small id='MguM5'></small><noframes id='MguM5'>

                      <i id='MguM5'><tr id='MguM5'><dt id='MguM5'><q id='MguM5'><span id='MguM5'><b id='MguM5'><form id='MguM5'><ins id='MguM5'></ins><ul id='MguM5'></ul><sub id='MguM5'></sub></form><legend id='MguM5'></legend><bdo id='MguM5'><pre id='MguM5'><center id='MguM5'></center></pre></bdo></b><th id='MguM5'></th></span></q></dt></tr></i><div id='MguM5'><tfoot id='MguM5'></tfoot><dl id='MguM5'><fieldset id='MguM5'></fieldset></dl></div>

                      • <bdo id='MguM5'></bdo><ul id='MguM5'></ul>