This blog post will show you how to use an Ansible playbook to create a Windows 10 virtual machine on Microsoft Azure.
Azure and Ansible
If you use Azure and use Ansible, you can create, manage, and delete resources on Microsoft Azure with Ansible.
Playbook
The following playbook will create a Windows 10 virtual machine on Microsoft Azure. The playbook will create a resource group called WSL. Make sure you set a login password to the VM before you run the playbook.
Once you run the playbook it will take betweeb 2 to 4 minutes for Ansible to provision the new VM.
--- - name: Create a resource group hosts: localhost connection: local gather_facts: no tasks: - name: Create a resource group azure_rm_resourcegroup: name: WSL location: westus tags: Environment: PROD - name: Create a virtual network azure_rm_virtualnetwork: resource_group: WSL name: wsl_network address_prefixes: "10.0.0.0/16" - name: Create a subnet azure_rm_subnet: resource_group: WSL virtual_network: wsl_network name: hosts address_prefix: "10.0.1.0/24" - name: Create a public IP address azure_rm_publicipaddress: resource_group: WSL allocation_method: Static name: windows10-pub-ip - name: Create a Network Security Group and Open RDP port azure_rm_securitygroup: resource_group: wsl name: wsl_nsg rules: - name: RDP protocol: Tcp destination_port_range: 3389 access: Allow priority: 100 direction: Inbound - name: Create a virtual network interface card azure_rm_networkinterface: resource_group: wsl name: wsl_nic virtual_network: wsl_network subnet: hosts public_ip_name: windows10-pub-ip security_group: wsl_nsg - name: Create a VM with managed disk azure_rm_virtualmachine: resource_group: WSL name: windows10 admin_username: azureradmin admin_password: SETPASSWORD managed_disk_type: Standard_LRS image: offer: windows-10 publisher: MicrosoftWindowsDesktop sku: 20h1-pro version: latest vm_size: Standard_D4 os_type: Windows network_interfaces: wsl_nic
Processing…
Success! You're on the list.
Whoops! There was an error and we couldn't process your subscription. Please reload the page and try again.