<bdo id='vLg5r'></bdo><ul id='vLg5r'></ul>

    1. <legend id='vLg5r'><style id='vLg5r'><dir id='vLg5r'><q id='vLg5r'></q></dir></style></legend>
      <tfoot id='vLg5r'></tfoot>
    2. <small id='vLg5r'></small><noframes id='vLg5r'>

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

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

      时间:2023-06-06
        <tbody id='KrTh6'></tbody>
        <bdo id='KrTh6'></bdo><ul id='KrTh6'></ul>

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

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

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

                本文介绍了使用 Ansible 设置不同的 ORACLE_HOME 和 PATH 环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我目前正在查询多个数据库并捕获查询结果

                Im currently querying multiple databases and capturing the results of the query

                我这样做的方式是,我编写一个复制shell脚本的任务,如下所示

                The way Im doing it is, Im writing a task which copies a shell script, something like below

                #!/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
                

                在剧本中,我写的任务如下:

                In the playbook, Im writing the task as below:

                - name: List Query [Host and DB]
                  shell: "/tmp/sqlscript/sql_select.sh {{item}} >> /tmp/sqlscript/output.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"
                  with_items: "{{ factor_dbs.split('\n') }}"
                

                但是我注意到不同的主机有不同的 ORACLE_HOME 和 PATHS.如何在剧本中定义这些变量,以便任务选择正确的 ORACLE_HOME 和 PATH 变量并成功执行任务

                However I have noticed that the different hosts have different ORACLE_HOME and PATHS. How can I define those variables in the playbook, so that the task picks the right ORACLE_HOME and PATH variables and execute the task successfully

                推荐答案

                您可以为每个主机定义特定于主机的变量.您可以编写您的库存文件,如:

                you can define host specific variables for each of the hosts. You can write your inventory file like:

                [is_hosts]
                greenhat ORACLE_HOME=/tmp
                localhost ORACLE_HOME=/sbin
                

                类似于 PATH 变量

                similarly for the PATH variable

                那么你的任务:

                演示结果的示例剧本:

                - hosts: is_hosts
                  gather_facts: false
                  vars:
                
                  tasks:
                    - name: task 1
                      shell: "env | grep -e PATH -e ORACLE_HOME"
                      environment:
                        # PATH: "{{ hostvars[inventory_hostname]['PATH']}}"
                        ORACLE_HOME: "{{ hostvars[inventory_hostname]['ORACLE_HOME'] }}"
                      register: shell_output
                
                    - name: print results
                      debug:
                        var: shell_output.stdout_lines
                

                示例输出,您可以看到 ORACLE_HOME 变量确实发生了变化,并且按照主机的定义:

                sample output, you can see ORACLE_HOME variable was indeed changed, and as defined per host:

                TASK [print results] ************************************************************************************************************************************************************************************************
                ok: [greenhat] => {
                    "shell_output.stdout_lines": [
                        "ORACLE_HOME=/tmp", 
                        "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
                    ]
                }
                ok: [localhost] => {
                    "shell_output.stdout_lines": [
                        "ORACLE_HOME=/sbin", 
                        "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
                    ]
                }
                

                这篇关于使用 Ansible 设置不同的 ORACLE_HOME 和 PATH 环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用terraform在easydns中自动添加dns条目? 下一篇:尽管在 Ansible 中提升了权限,但仍无法运行脚本

                相关文章

                最新文章

                    <bdo id='qKCkC'></bdo><ul id='qKCkC'></ul>

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

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

                  3. <small id='qKCkC'></small><noframes id='qKCkC'>