VNETのリソースグループとは異なるリソースグループにNICを作成する場合は ”virtual_network” をリソースIDで指定すればOK。
NGパターン
# ネットワークインターフェースの作成
- name: Create a network interface
azure_rm_networkinterface:
name: nic01
resource_group: test_resource_group
virtual_network: test_vnet
subnet_name: test_subent
ip_configurations:
- name: ipconfig
primary: True
private_ip_address: 192.168.3.1
private_ip_allocation_method: Static
エラーメッセージ
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error creating or updating network interface ansible02_nic - Azure Error: InvalidResourceReference\nMessage: Resource /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/ansible_azure/providers/Microsoft.Network/virtualNetworks/test_vnet/test_subenet/testsubnet referenced by resource /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/ansible_azure/providers/Microsoft.Network/networkInterfaces/ansible02_nic was not found. Please make sure that the referenced resource exists, and that both resources are in the same region."}
OKパターン
# ネットワークインターフェースの作成
- name: Create a network interface
azure_rm_networkinterface:
name: nic01
resource_group: test_resource_group
virtual_network: "/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/test_vnet"
subnet_name: test_subent
ip_configurations:
- name: ipconfig
primary: True
private_ip_address: 192.168.3.1
private_ip_allocation_method: Static
<参考サイト>
azure_rm_networkinterface cannot create interface if virtual network is in different resource group
コメント