# azure\_rm\_virtualmachine error when using zeros...

**URL:** <https://forum.ansible.com/t/azure-rm-virtualmachine-error-when-using-zeros/28374>\
**Category:** Ansible Project\
**Tags:** azure, windows\
**Created:** [August 20, 2018, 6:51pm UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-error-when-using-zeros/28374 "2018-08-20T18:51:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Rousse](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@Eric\_Rousse](https://forum.ansible.com/u/Eric_Rousse)\
**Post date:** [August 20, 2018, 6:51pm UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-error-when-using-zeros/28374/1 "2018-08-20T18:51:55Z")

</div>

Hello,

I have a case here were I need to create VMs with a name based on a sequence and that sequence will generate numbers from 01 to 05 for example.  
When I use the same sequence with azure\_rm\_networkinterface and azure\_rm\_securitygroup, is works fine and uses the same value for the name.

Once I get to that part, the vmName gets all his 0 replaced by 8=\*, so yeah, eight asterisk. I’ve also hardcode the VM part with a static value, with vmtestelab111, so then the error message about the vmName goes away. But then again I get an error about the sku, which contains 0. So is it really an issue with the module ? Or I’m doing something wrong ? At the bottom the original error message.

- name: “get {{vmadminuser}} password”  
command: \>  
az keyvault secret show --vault-name “{{ keyvault.name }}” --name “{{ vmadminuser }}” --query “{token: value}”  
no\_log: true  
register: pass
- debug:  
msg: “nsg{{vmName}}”
- name: Create security group  
azure\_rm\_securitygroup:  
resource\_group: “{{ rg\_name }}”  
name: “nsg{{ vmName }}”  
rules:
- name: “rdp”  
protocol: Tcp  
destination\_port\_range: 3389  
source\_address\_prefix: “{{srcAddressPrefix}}”  
access: Allow  
priority: 100  
direction: Inbound
- name: “winrm”  
protocol: Tcp  
destination\_port\_range: 5589  
source\_address\_prefix: “{{srcAddressPrefix}}”  
access: Allow  
priority: 101  
direction: Inbound
- debug:  
msg: “nic{{vmName}}”
- name: Create NIC  
azure\_rm\_networkinterface:  
resource\_group: “{{ rg\_name }}”  
name: “nic{{ vmName }}”  
virtual\_network: “{{ env[envName].vnet.ressourceid }}”  
subnet: “{{ env[envName].subnet.name }}”  
public\_ip\_name: None  
ip\_configurations:
- name: ipconfig1  
primary: True  
security\_group: “nsg{{ vmName }}”  
os\_type: “{{ srvtype[os].os }}”
- debug:  
msg: “{{vmName}}”
- name: Create VM  
azure\_rm\_virtualmachine:  
resource\_group: “{{ rg\_name }}”  
name: “vmtestelab111”  
admin\_username: “{{ vmadminuser }}”  
admin\_password: “{{ pass }}”  
image:  
offer: “{{ srvtype[os].offer }}”  
publisher: “{{ srvtype[os].publisher }}”  
sku: “{{ srvtype[os].sku }}”  
version: “{{ srvtype[os].version }}”  
vm\_size: Standard\_D2s\_v3  
managed\_disk\_type: Standard\_LRS  
network\_interfaces: “nic{{ vmName }}”  
os\_type: “{{ srvtype[os].os}}”  
tags:  
niveau\_service: “{{ niveau\_service }}”  
changed\_when: false

{  
“\_ansible\_parsed”: true,  
“invocation”: {  
“module\_args”: {  
“virtual\_network\_resource\_group”: null,  
“resource\_group”: “rgtestelab**1",  
“public\_ip\_allocation\_method”: “Static”,  
“image”: {  
“sku”: "2**16-Datacenter”,  
“publisher”: “MicrosoftWindowsServer”,  
“version”: “2 **16.127.2** 18**613",  
“offer”: “WindowsServer”  
},  
“secret”: null,  
“managed\_disk\_type”: “Standard\_LRS”,  
“ssh\_public\_keys”: null,  
“storage\_container\_name”: “vhds”,  
“allocated”: true,  
“ssh\_password\_enabled”: true,  
“storage\_blob\_name”: null,  
“remove\_on\_absent”: [  
“all”  
],  
“availability\_set”: null,  
“append\_tags”: true,  
“cloud\_environment”: null,  
“cert\_validation\_mode”: null,  
“short\_hostname”: null,  
“virtual\_network\_name”: null,  
“state”: “present”,  
“subnet\_name”: null,  
“admin\_password”: " **‘stderr\_lines’: , ‘changed’: True, ‘end’: ‘2** 18-8-2 18:\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*:21.8155’, ‘stdout’: '**\n\*\*\*\*\*\*\*\*\n\*\*\*\*\*\*\*\*’, ‘cmd’: [‘**', ' **’, ‘**', ' **’, ‘**', 'kvlabapp **1’, ‘**', ' **’, ‘**', '**’], ‘rc’:**, ‘failed’: False, ‘stderr’: ‘’, ‘delta’: '**‘, ‘stdout\_lines’: [’**', ' **', ‘**'], ‘start’: ' **’**",  
“network\_interface\_names”: [  
"nicvmtestelab **1** 2"  
],  
“subscription\_id”: null,  
“location”: null,  
“profile”: null,  
“tags”: {  
“niveau\_service”: “9a5”  
},  
“started”: true,  
“open\_ports”: null,  
“restarted”: false,  
“plan”: null,  
“client\_id”: null,  
“auth\_source”: null,  
“vm\_size”: “Standard\_D2s\_v3”,  
“password”: null,  
“tenant”: null,  
“name”: "vmtestelab **1** 2",  
“ad\_user”: null,  
“network\_interfaces”: "nicvmtestelab **1** 2",  
“admin\_username”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,  
“custom\_data”: null,  
“api\_profile”: “latest”,  
“os\_type”: “Windows”,  
“storage\_account\_name”: null,  
“data\_disks”: null,  
“os\_disk\_caching”: “ReadOnly”  
}  
},  
“changed”: false,  
“\_ansible\_no\_log”: false,  
“msg”: "Error creating or updating virtual machine vmtestelab**1\*\*\*\*\*\*\*\*2 - Azure Error: InvalidParameter\nMessage: The supplied password must be between 8-123 characters long and must satisfy at least 3 of password complexity requirements from the following: \r\n1) Contains an uppercase character\r\n2) Contains a lowercase character\r\n3) Contains a numeric digit\r\n4) Contains a special character\r\n5) Control characters are not allowed\nTarget: adminPassword”  
}

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [August 20, 2018, 7:12pm UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-error-when-using-zeros/28374/2 "2018-08-20T19:12:46Z")

</div>

I think this is something you should file an issue to change if the other modules accept names like that or it may be this module only accepts names that way. I took a quick look at the issues and did not see anything reported.

---

<div class="post-metadata">

**Author:** ![Eric\_Rousse](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@Eric\_Rousse](https://forum.ansible.com/u/Eric_Rousse)\
**Post date:** [August 20, 2018, 7:18pm UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-error-when-using-zeros/28374/3 "2018-08-20T19:18:05Z")

</div>

Yeha, at first I was unsure if it was maybe me. But I did a lot of testing, I was about to create a bug report. Thanks for the confirmation Jonathan! 🙂
