我正在尝试在名为“net-interface”的资源组中创建网络接口,并将其与属于名为“virtual-net”的资源组的虚拟网络相关联。我能够手动完成,但是当我使用Ansible时,它期望虚拟网络位于网络接口资源组“net-interface”中。甚至尝试为虚拟网络提供完整的URI。
azure_rm_networkinterface:
name: testnetworkinfrastructure
resource_group: testsourcegroup1
virtual_network_name: /subscriptions/xxxxxxxxxxxxxxxxxxxxx/resourceGroups/testsourcegroup1/providers/Microsoft.Network/virtualNetworks/testvirtualnetwork
subnet_name: testsubnet
security_group_name: testsecuritygroup
location: West Europe
state: present
失败:[localhost](item = ansible20-nic-01)=> {“failed”:true,“item”:“ansible20-nic-01”,“msg”:“错误:在虚拟网络中获取子网testsubnet /subscriptions/xxxxxxxxxxxxxxxxxxx/resourceGroups/testsourcegroup1/providers/Microsoft.Network/virtualNetworks/testvirtualnetwork - Azure错误:ResourceNotFound \ nMessage:找不到资源组“testsourcegroup1”下的资源“Microsoft.Network/virtualNetworks/subscriptions”。“}
我做错了吗?或者有解决方法吗?
答案 0 :(得分:1)
不幸的是,您的案例似乎没有涵盖azure_rm_networkinterface
模块的当前实现。
它与网络接口在同一资源组中checks for the presence of the subnet,并且没有正常地显示您收到的消息:
def get_subnet(self, vnet_name, subnet_name):
self.log("Fetching subnet {0} in virtual network {1}".format(subnet_name, vnet_name))
try:
subnet = self.network_client.subnets.get(self.resource_group, vnet_name, subnet_name)
except Exception as exc:
self.fail("Error: fetching subnet {0} in virtual network {1} - {2}".format(subnet_name, vnet_name, str(exc)))
从简短的检查来看,Azure SDK for Python看起来需要指定资源组,因此您可以:
自定义azure_rm_networkinterface
模块以指定子网资源组,或
使用azure_rm_deployment
创建Azure RM模板部署。