2
私はこの構造を持っています。各ホストについて、この構造は多かれ少なかれアイテムを有することができる。あるタスクでは、特定の名前でモジュールが定義されているかどうかを知りたい。オブジェクトフィールドの値でリスト内のオブジェクトを検索可能
---
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
これを動作させるにはどうすればよいですか? 良い方法がありますか?