2.3. ネットワークデバイスからのファクトの収集
Gather_facts キーワードは、標準化されたキーと値のペアで、ネットワークデバイスファクトを収集しやすくなります。これらのネットワークファクトをさらなるタスクにフィードして、ネットワークデバイスを管理できます。以下に示すように、ネットワーク *_facts モジュール (arista.eos.eos_facts など) で Gather_network_resources パラメーターを使用して、デバイス設定のサブセットを返すこともできます。
- hosts: arista
gather_facts: True
gather_subset: interfaces
module_defaults:
arista.eos.eos_facts:
gather_network_resources: interfaces
Playbook は以下のインターフェイスのファクトを返します。
"network_resources": {
"interfaces": [
{
"description": "test-interface",
"enabled": true,
"mtu": "512",
"name": "Ethernet1"
},
{
"enabled": true,
"mtu": "3000",
"name": "Ethernet2"
},
{
"enabled": true,
"name": "Ethernet3"
},
{
"enabled": true,
"name": "Ethernet4"
},
{
"enabled": true,
"name": "Ethernet5"
},
{
"enabled": true,
"name": "Ethernet6"
},
]
}
Gather_network_resources は、サポートされているすべてのリソース (interfaces/bgp/ospf/etc`) のファクトとして設定データをレンダリングしますが、gather_subset は主に運用データをフェッチするために使用されます。
これらのファクトを保存し、eos_interfaces リソースモジュールなどの別のタスクで直接使用できます。