Q: ansible to provision azure loadbalncer with private ip I was trying to provision an Azure load-balancer with only a private IP address in an existing subnet. I could accomplish this with the below code.
 - name: create load balancer
  azure_rm_loadbalancer:
    resource_group: "{{resource_group_name}}"
    name: my_new_lb
    frontend_ip_configurations:
      - name: frontendipconf0
        private_ip_address:
        private_ip_allocation_method: dynamic
       subnet: /subscriptions/1234445sdffew11111111/resourceGroups/RG_NAME/providers/Microsoft.Network/virtualNetworks/vnet-stage/subnets/default
    backend_address_pools:
      - name: backend_pool1
    probes:
      - name: prob0
        port: 80
    load_balancing_rules:
      - name: lbrbalancingrule0
        frontend_ip_configuration: frontendipconf0
        backend_address_pool: backend_pool1
        frontend_port: 8000
        backend_port: 443
        probe: prob0

But is there a way we can provision a loadbalancer without providing a complete subnet id in the task file?

A: I could resolve the issue with the help of azure_rm_resource_info as well. Adding the script below.
azure_rm_resource_info:
    api_version: '2018-08-01'
    resource_group: "{{ resource_group_name }}"
    provider: network
    resource_type: virtualnetworks
    resource_name: "{{ vnet_name }}"
    subresource:
      - type: subnets
        name: "{{ subnet_name }}"
  register: subnet
- name: create load balancer
  azure_rm_loadbalancer:
    resource_group: "{{resource_group_name}}"
    name: lb_name
    frontend_ip_configurations:
      - name: frontendipconf0
        private_ip_address:
        private_ip_allocation_method: dynamic
        subnet: "{{subnet.response[0].id }}"


A: If you want to provision the load balancer with a private IP address, then you must associate a subnet to the load balancer, so I think an existing subnet resource id is necessary. It's impossible not to provide a complete subnet id in the task file.
Update:
Here is the example to get the virtual network info:
- name: Get the Load Balancer info
  azure_rm_virtualnetwork_info:
    resource_group: "{{ resource_group_name }}" 
    name: "{{ vnet_name }}" 
  register: vnet

Then you can input the subnet id in the load balancer like this:
subnet: "{{ vnet.virtualnetworks[0].subnets[0].id }}"

You can get the VNet info and change the subnet you want to use. Please read the azure_rm_virtualnetwork_info example carefully.
