Ansible and Azure

14 views
Skip to first unread message

Lucas Chies

unread,
Sep 3, 2019, 10:57:10 AM9/3/19
to Ansible Project
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?

Wawrzek Niewodniczanski

unread,
Sep 3, 2019, 11:38:15 AM9/3/19
to ansible...@googlegroups.com
On Tue, 3 Sep 2019 at 15:57, Lucas Chies <lch...@gmail.com> wrote:
>
> 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

--
Dr Wawrzyniec Niewodniczański or Wawrzek for short
PhD in Quantum Chemistry & MSc in Molecular Engineering
WWW: http://wawrzek.name E-MAIL: jo...@wawrzek.name
Linux User #177124

Lucas Chies

unread,
Sep 3, 2019, 1:20:32 PM9/3/19
to Ansible Project
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.

Wawrzek Niewodniczanski

unread,
Sep 4, 2019, 4:16:58 AM9/4/19
to ansible...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages