Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Windows VM created by VMSS through Bastion Host

I have created my infrastructure through Terraform, the relevant (Azure) resources are

  • Application Gateway
  • VMSS (Virtual Machine Scale Set)
  • Windows VMs => Created/Destroyed by VMSS (Windows VM are in private subnet, and HTTPS access is through Application Gateway)
  • Ubuntu based Bastion Host (for RDP and ansible configuration)

So far I am able to configure one of my windows VM through Ansible using psrp protocol, but that was only possible because I knew the private IPV4 of my VM (added the private IP to host file of bastion vm). How can I do it without knowing the IP address(es)?

My other question is how will the Ansible know a new VM has been created and it needs to be configured?

Edit
If you think this is not the best approach, please guide me on how to do it properly? Should I use Packer with custom image? OR is there any other option? The main configuration I want to do is enable IIS and install a few programs like GIT.

Thank you.

like image 780
Atif Farrukh Avatar asked Jun 26 '20 10:06

Atif Farrukh


People also ask

Do we need public for the VMs to connect via Bastion?

When you connect to a VM using Azure Bastion, you don't need a public IP address for your VM. If you aren't using the public IP address for anything else, you can dissociate it from your VM. To dissociate a public IP address from your VM, use the following steps: Go to your virtual machine and select Networking.

Is bastion host a VM?

Azure Bastion is a fully managed service that provides more secure and seamless Remote Desktop Protocol (RDP) and Secure Shell Protocol (SSH) access to virtual machines (VMs) without any exposure through public IP addresses.


1 Answers

The best way IMO is to use a dynamic inventory. Although the doc examples are detailed for clobber and EC2, you will find more info on the included scripts with examples for Azure.

Once you have your dynamic inventory in place, you can refresh it with meta: refresh_inventory whenever you need to.

like image 135
Zeitounator Avatar answered Oct 24 '22 06:10

Zeitounator