我正在使用 IBM z/OS CICS collection对于 Ansible。我需要能够找到包含特定程序的所有 CICS 区域,并定期将其自动化。
我已经设置了 CMCI 并对其进行了测试。我还可以获得这样的所有程序:
tasks:
- name: 'Get all programs'
delegate_to: 'localhost'
ibm.ibm_zos_cics.cmci_get:
type: 'CICSProgram'
scope: [redacted]
我不太确定应该如何过滤程序或如何将结果映射到 CICS 区域名称,并将其作为逗号分隔的列表返回。
最佳答案
你可以试试这样的剧本,它使用 filter查找 PROGRAM
的所有实例具有特定名称的资源。
然后它使用内置的debug
模块结合 Jinja 过滤器提取每个区域的名称 PROGRAM
被发现,最后将它们加入一个逗号分隔的列表中:
---
- name: CICS CMCI Report
collections:
- ibm.ibm_zos_cics
hosts: 'localhost'
gather_facts: 'false'
vars:
program_name: MYPROG
context: CICSPLEX
cmci_host: 'example.com'
cmci_port: 12345
tasks:
- name: Make sure CMCI module dependencies are installed
pip:
name:
- requests
- xmltodict
- name: Find all instances of a particular program
cmci_get:
context: '{{ context }}'
cmci_host: '{{ cmci_host }}'
cmci_port: '{{ cmci_port }}'
type: 'CICSProgram'
resources:
filter:
program: '{{ program_name }}'
register: result
- name: Extract the CICS region names from the program records
debug:
msg: "{{ result.records | map(attribute='eyu_cicsname') | join(',') }}"
关于ansible - 通过 Ansible 查找包含程序的所有 CICS 区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66264315/