ansible:如何显示使用 with_items 的任务的输出?

ansible: how do I display the output from a task that using with_items?

这里是 Ansible 新手 希望我的问题有一个简单的解决方案

我正在尝试 运行 SQL 跨越一个节点上的多个 Oracle 数据库。我从 ps -ef 生成数据库列表并使用 with_items 传递 dbname 值。

我的问题是如何显示每个数据库 运行ning select 语句的输出?

 tasks:

 

    - name: Exa check | find db instances

      become: yes

      become_user: oracle

      shell: |

         ps -ef|grep pmon|grep -v grep|grep -v ASM|awk '{ print  }'|cut -d '_' -f3

      register: instance_list_output

      changed_when: false

      run_once: true

 

    - shell: |

        export ORAENV_ASK=NO; export ORACLE_SID={{ item }}; export ORACLE_HOME=/u01/app/oracle/database/12.1.0.2/dbhome_1; source /usr/local/bin/oraenv; $ORACLE_HOME/bin/sqlplus -s \"/ as sysdba\"<< EOSQL

        select * from v$instance;

         EOSQL

      with_items:

      - "{{ instance_list_output.stdout_lines }}"

      register: sqloutput

      run_once: true

下面的循环可能有效。

- debug:
    msg: "{{ item.stdout }}"
  loop: "{{ sqloutput.results }}"

如果不看变量的内容再决定怎么用

- debug: var=sqloutput