2
我有这样的结构。对于每个主机,这个结构可能有更多或更少的项目。在一个任务中,我想知道是否有一个用特定名称定义的模块。Ansible通过对象字段的值在列表中找到对象
---
web_module_list:
- module_name: LaunchPad
module_version: 1.4.0
- module_name: Manager
module_version: 1.6.0
- module_name: NetworkInventory
module_version: 1.1.4
- module_name: Reporting
module_version: 1.0.18
- module_name: TriadJ
module_version: 4.1.0-1.1.7
比如我想知道,如果MODULE_NAME报告定义,这样我包括一组它的任务。
- set_fact:
reporting: if the web_module_list contains an item with module_name Reporting then true else false
woprinting: if the web_module_list contains an item with module_name WorkOrderPrinting then true else false
- name: If the reporting module is listed in inventory then execute its tasks
include: reporting.yml
when: reporting
- name: If the work order printing module is listed in inventory then execute its tasks
include: woprinting.yml
when: woprinting
我如何得到这个工作? 有没有更好的方法?