azure_rm_virtualmachine and ssh_public_key dict

171 views
Skip to first unread message

Steven Carter

unread,
Jul 9, 2016, 4:39:00 PM7/9/16
to Ansible Project
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. 

Merv Merv

unread,
Jul 20, 2016, 10:53:18 AM7/20/16
to Ansible Project
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"}

:(

Merv Merv

unread,
Jul 20, 2016, 10:53:18 AM7/20/16
to Ansible Project
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)"}

On Sunday, July 10, 2016 at 2:09:00 AM UTC+5:30, Steven Carter wrote:

Praneeth Reddy Putha

unread,
Jul 20, 2016, 10:53:23 AM7/20/16
to Ansible Project
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

Merv Merv

unread,
Jul 21, 2016, 3:51:34 AM7/21/16
to Ansible Project
Hi Praneeth,

Is it working when you provide the subnet name too?

Thanks.
Merv
Reply all
Reply to author
Forward
0 new messages