# azure\_rm\_virtualmachine and ssh\_public\_key dict

**URL:** <https://forum.ansible.com/t/azure-rm-virtualmachine-and-ssh-public-key-dict/21971>\
**Category:** Ansible Project\
**Created:** [July 9, 2016, 8:39pm UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-and-ssh-public-key-dict/21971 "2016-07-09T20:39:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Carter](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@Steven\_Carter](https://forum.ansible.com/u/Steven_Carter)\
**Post date:** [July 9, 2016, 8:39pm UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-and-ssh-public-key-dict/21971/1 "2016-07-09T20:39:00Z")

</div>

When I do:

- name: Create the Host VM  
azure\_rm\_virtualmachine:  
state: present  
resource\_group: ‘{{ cloud\_tag }}’  
name: ‘{{ cloud\_tag }}-host’  
vm\_size: ‘Standard\_DS1\_v2’  
storage\_account: ‘{{ storage\_group }}’  
admin\_username: ‘azureuser’  
ssh\_password\_enabled: false  
ssh\_public\_keys:  
path: ‘/home/azureuser/.ssh/authorized\_keys’  
key\_data: ‘{{ ssh\_public\_key }}’  
network\_interfaces: ‘host\_inside\_interface’  
image:  
offer: CentOS  
publisher: OpenLogic  
sku: ‘7.1’  
version: latest  
register: host\_facts

I get this:

fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “invocation”: {“module\_args”: {“admin\_username”: “azureuser”, “allocated”: true, “append\_tags”: true, “image”: {“offer”: “CentOS”, “publisher”: “OpenLogic”, “sku”: “7.1”, “version”: “latest”}, “name”: “stevenca-hybrid-cloud-host”, “network\_interface\_names”: “host\_inside\_interface”, “network\_interfaces”: “host\_inside\_interface”, “os\_disk\_caching”: “ReadOnly”, “os\_type”: “Linux”, “public\_ip\_allocation\_method”: “Static”, “remove\_on\_absent”: [“all”], “resource\_group”: “stevenca-hybrid-cloud”, “restarted”: false, “ssh\_password\_enabled”: false, “ssh\_public\_keys”: {“key\_data”: “ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDgEwX8DzneLc/WTs1hT7ff0DPoSEKKI390pZEYF1FylDhBLswhUW/oXoUIGYprc4pMzaoFtcbsojJMkd7psMNEqJvy+IUUCmsX3OlUJw1q3vFt26oHyVUuvaGOoV2GinVeMp1GyCy9b2lsFIpBB1L31jAs/Qdb66TowhYhbhIcLU65xCE3X9LgBWWXRFTeLVC9OUBma0ZDHuvnrfw6zPmbuTzyVDOKdg0mxyec1+QH3OWKCSDRU0790U2xekFsEazmsJx1ZuqLt/pa+pDngd6cB9RZ/epHYCbvkB305lhXS+kfnweo8h59tLQxUDMft1YmDGZlPWCm8fuaIBFi6hn stevenca@stevenca-login”, “path”: “/home/azureuser/.ssh/authorized\_keys”}, “started”: true, “state”: “present”, “storage\_account”: “stevencahybridcloud”, “storage\_account\_name”: “stevencahybridcloud”, “storage\_container\_name”: “vhds”, “vm\_size”: “Standard\_DS1\_v2”}, “module\_name”: “azure\_rm\_virtualmachine”}, “msg”: “argument ssh\_public\_keys is of type \<type ‘dict’\> and we were unable to convert to list”}

I’ve tried a few permutations with no success. ‘{{ ssh\_public\_key }}’ is the same that I put into a template with azure\_rm\_deployment that works. Any guidance is appreciated.

Thanks,

Steven.

---

<div class="post-metadata">

**Author:** ![Praneeth\_Reddy\_Putha](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@Praneeth\_Reddy\_Putha](https://forum.ansible.com/u/Praneeth_Reddy_Putha)\
**Post date:** [July 18, 2016, 9:00pm UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-and-ssh-public-key-dict/21971/2 "2016-07-18T21:00:04Z")

</div>

Hi Steven,

Please use in below format.

- name: Create the Host VM  
azure\_rm\_virtualmachine:  
state: present  
resource\_group: ‘{{ cloud\_tag }}’  
name: ‘{{ cloud\_tag }}-host’  
vm\_size: ‘Standard\_DS1\_v2’  
storage\_account: ‘{{ storage\_group }}’  
admin\_username: ‘azureuser’  
ssh\_password\_enabled: false  
ssh\_public\_keys:
- path: /home/azureuser/.ssh/authorized\_keys’  
key\_data: ‘{{ ssh\_public\_key }}’  
network\_interfaces: ‘host\_inside\_interface’  
image:  
offer: CentOS  
publisher: OpenLogic  
sku: ‘7.1’  
version: latest  
register: host\_facts

Regards,  
Praneeth

---

<div class="post-metadata">

**Author:** ![Merv\_Merv](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@Merv\_Merv](https://forum.ansible.com/u/Merv_Merv)\
**Post date:** [July 20, 2016, 9:42am UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-and-ssh-public-key-dict/21971/3 "2016-07-20T09:42:30Z")

</div>

Even i am facing this.

“module\_name”: “azure\_rm\_virtualmachine”}, “msg”: “argument ssh\_public\_keys is of type \<type ‘dict’\> and we were unable to convert to list”}

☹

---

<div class="post-metadata">

**Author:** ![Merv\_Merv](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@Merv\_Merv](https://forum.ansible.com/u/Merv_Merv)\
**Post date:** [July 20, 2016, 11:30am UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-and-ssh-public-key-dict/21971/4 "2016-07-20T11:30:05Z")

</div>

Hey you can make the following -

path: ‘/home/azureuser/.ssh/authorized\_keys’  
key\_data: ‘{{ ssh\_public\_key }}’

into a list and use them.

But I am facing a different issue now.

fetching subnet xxxxx - get() takes at least 4 arguments (3 given)"}

---

<div class="post-metadata">

**Author:** ![Merv\_Merv](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@Merv\_Merv](https://forum.ansible.com/u/Merv_Merv)\
**Post date:** [July 21, 2016, 7:51am UTC](https://forum.ansible.com/t/azure-rm-virtualmachine-and-ssh-public-key-dict/21971/5 "2016-07-21T07:51:34Z")

</div>

Hi Praneeth,

Is it working when you provide the subnet name too?

Thanks.  
Merv
