Packer set ssh key in Bionic Ubuntu Cloud Image(OVA)

24 views
Skip to first unread message

Simar Arora

unread,
Jan 31, 2019, 7:52:03 PM1/31/19
to Packer
Hi,

I am trying to provision Ubuntu cloud image in my virtual box(OVA format), the cloud image does not come with default login credentials and needs ssh key pair to be inserted in VM. After some research, I found that it can be done with cloud-init, wondering if this can be done with Packer as well? 

 
{
"builders":[{

  "type": "virtualbox-ovf",
  "source_path": "ubuntu-bionic-18.04-cloudimg.ovf",
  "ssh_private_key_file": "~/development/packer_scripts/ssh/id_rsa",
  "shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
   "vboxmanage": [
    ["modifyvm", "{{.Name}}", "--memory", "1024"],
    ["modifyvm", "{{.Name}}", "--cpus", "2"],
    [ "modifyvm", "{{.Name}}", "--uart1", "0x3F8", "4" ]
  ],
   "boot_command":[
"<esc><wait>",
"<esc><wait>",
"<esc><wait>"
   ]
}
]
}


Virt Man

unread,
Feb 1, 2019, 3:01:33 AM2/1/19
to packe...@googlegroups.com
You can use file directive to copy the ssh key while building the image.
https://packer.io/docs/builders/file.html


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/35c47410-efb7-4b48-9af9-edc754adbc16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rickard von Essen

unread,
Feb 1, 2019, 5:03:32 AM2/1/19
to packe...@googlegroups.com
Actually you can't copy the pub key if you can't log in. You can use boot_command to login on the console and add the pubkey if you have any login enabled.

There have been a recent discussion to automate some of this in https://github.com/hashicorp/packer/issues/7225 

VirtualBox is not a "cloud" so cloud-init will not just work (there is no API to handle the pubkey with), but you could prepare a config-drive before running Packer, for more info see the issue above.

Reply all
Reply to author
Forward
0 new messages