I tried with the following playbook and its not working. Not sure what I am missing here.
hosts: localhost
connection: local
gather_facts: no
vars_files:
- vars/azure.yml
tasks:
- name: create VM
azure:
name: '{{ vm_name }}'
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:
- { name: "{{ vm_names_list }}" }
register : azure
- name : Debug Azure output
debug :
var : azure
I have mentioned my vm_names_list
like this :
vm_names_list:
- "loferVM123"
- "loferVM234"
It does not do what I expect. I expected it to create three VMs. But it creates only one VM. In the debug output it gives me the items in the list but only creates one VM.
This is the debug output:
"virtual_network_name": "myVirtualNetwork"
},
"invocation": {
"module_args": "",
"module_name": "azure"
},
"item": {
"vm_name": [
"loferVM123",
"loferVM234"
]
},
"public_dns_name": "lofervm175.cloudapp.net"
My variable file:
subscription_id: "ID"
certificate_path: "/path/to/certs/mycert.pem"
image_name: "5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-67-20150815"
storage_account_name: "mystorageacc"
virtual_network_name: "myVirtualNetwork"
username: "user"
password: "password"
vm_name: "Testvm"
vm_names_list:
- "loferVM123"
- "loferVM234"
role_size: "Small"
location: "Central US"
data_disk_size: "100"
commitlog_disk_size: "10"
This is the output from azure-cli vm show
data: DNSName "lofervm234.cloudapp.net"
data: Location "Central US"
data: VMName "loferVM234"
data: IPAddress "10.0.2.6"
data: InstanceStatus "ReadyRole"
data: InstanceSize "Small"
data: Image "5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-67-20150815"
data: OSDisk hostCaching "ReadWrite"
data: OSDisk name "loferVM234-loferVM234-0-201510262116050841"
data: OSDisk mediaLink "http://portalvhdskswbj32fl5cx8.blob.core.windows.net/vhds/loferVM234-loferVM234-2015-10-26.vhd"
data: OSDisk sourceImageName "5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-67-20150815"
data: OSDisk operatingSystem "Linux"
data: OSDisk iOType "Standard"
data: DataDisks 0 hostCaching "None"
data: DataDisks 0 label "loferVM234-loferVM234-loferVM234-0"
data: DataDisks 0 name "loferVM234-loferVM234-0-201510262116380749"
data: DataDisks 0 logicalDiskSizeInGB 100
data: DataDisks 0 mediaLink "https://portalvhdskswbj32fl5cx8.blob.core.windows.net/vhds/loferVM234-b73613825dfb0bcb.vhd"
data: DataDisks 0 iOType "Standard"
data: DataDisks 1 hostCaching "None"
data: DataDisks 1 label "loferVM234-loferVM234-loferVM234-1"
data: DataDisks 1 name "loferVM234-loferVM234-1-201510262117180308"
data: DataDisks 1 logicalUnitNumber 1
data: DataDisks 1 logicalDiskSizeInGB 100
data: DataDisks 1 mediaLink "https://portalvhdskswbj32fl5cx8.blob.core.windows.net/vhds/loferVM234-cf18946abcbfe4c8.vhd"
data: DataDisks 1 iOType "Standard"
data: ReservedIPName ""
data: VirtualIPAddresses 0 address "104.43.202.234"
data: VirtualIPAddresses 0 name "loferVM234ContractContract"
data: VirtualIPAddresses 0 isDnsProgrammed true
data: Network Endpoints 0 localPort 22
data: Network Endpoints 0 name "TCP-22"
data: Network Endpoints 0 port 22
data: Network Endpoints 0 protocol "tcp"
data: Network Endpoints 0 virtualIPAddress "104.43.202.234"
data: Network Endpoints 0 enableDirectServerReturn false
data: Network Endpoints 0 idleTimeoutInMinutes 4