How to create multiple virtual machines in azure using ansible

try this:

- hosts: localhost
  connection: local
  gather_facts: no
  vars_files:
    - vars/azure.yml
  tasks:
    - name: create VM
      azure:
        name: '{{ item }}'
        role_size: '{{ role_size }}'
        image: '{{ image_name }}'
        location: '{{ location }}'
        user: '{{ username }}'
        password: '{{ password }}'
        subscription_id: '{{ subscription_id }}'
        management_cert_path: '{{ certificate_path }}'
        storage_account: '{{ storage_account_name }}'
        virtual_network_name: '{{ virtual_network_name }}'
        wait: yes
      with_items:
          - "{{ vm_names_list }}" }
      register : azure

    - name : Debug Azure output
      debug :
        var : azure

Is the trailing } on

  • “{{ vm_names_list }}” }
    intended / needed?

nope, that is a typo