packerでbuild時にvirtualbox-iso: sudo: sorry, you must have a tty to run sudo
がでた時の備忘録です。
configファイルのbuildersセクションに以下を追加すると解決。
"ssh_pty" : "true"
以下利用しているbuildersセクション
"builders":[{
"type": "virtualbox-iso",
"guest_os_type": "RedHat_64",
"iso_url": "http://ftp.iij.ad.jp/pub/linux/centos/6.7/isos/x86_64/CentOS-6.7-x86_64-minimal.iso",
"iso_checksum": "9381a24b8bee2fed0c26896141a64b69",
"iso_checksum_type": "md5",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "3000s",
"vm_name": "box",
"http_directory": "./",
"boot_wait": "30s",
"boot_command":[
"<esc><wait>",
"linux ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg ",
"<enter><wait>"
],
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"ssh_pty" : "true"
}],