Hello guys,
I’ve a doubt … I’ve a ansible script that create an windows VM on Azure, but I already have the vnet created in and hosted in another Resource Group.
I don’t know how can I create my script to put this VM in the created vNet.
I tried to put this:
virtual_network_name:
resource_group: rg-fgl-network
name: vnet-fgl
location: brazilsouth
But is not working.
Someone already tried this?
Hello guys,
I've a doubt ... I've a ansible script that create an windows VM on Azure, but I already have the vnet created in and hosted in another Resource Group.
I don't know how can I create my script to put this VM in the created vNet.
I tried to put this:
[...]
But is not working.
What's the error message? Vnet and VM doesn't need to be in on RG.
Wawrzek
Hi @Wawrzek,
Yes, they need be in a RG. But in my case the VM will be in one RG and the vNet already existing in another RG.
But I achieve this using this :
- name: Create Azure VM
hosts: localhost
connection: local
vars:
resource_group_vnet: rgname
vnet_name: vnetname
subnet_name: subnetname
and after the image information, I put this:
virtual_network_resource_group: “{{ resource_group_vnet }}”
virtual_network_name: “{{ vnet_name }}”
subnet_name: “{{ subnet_name }}”
After this, the vm was created in your resource and consume the vNet in another RG.
Tks.
Hi Lucas,
Yes, they need be in a RG. But in my case the VM will be in one RG and the vNet already existing in another RG.
What I meant is they don't need to be in the same RG, but I see that
you find the right approach out.
Wawrzek