这周,我在家里的实验室里学习如何使用包装器,在那里我有一台ESXi 7主机。
我只是尝试部署一个Ubuntu 18.04虚拟机,但是在构建结束时,我在打包控制台中收到以下错误:
sudo: no tty present and no askpass program specified
这就是我所做的。
我运行的命令:
sudo packer build -var-file=variables.json build.json
在ESXi中,我看到了VM的构建、完成和重启,它得到了一个IP地址,在我看到上面的消息后,在打包删除VM之前,我得到了一个简短的SSH提示符。
这是完整的错误:
==> Ubuntu-18.04: Connecting to VNC over websocket...
==> Ubuntu-18.04: Waiting 10s for boot...
==> Ubuntu-18.04: Typing the boot command over VNC...
==> Ubuntu-18.04: Waiting for SSH to become available...
==> Ubuntu-18.04: Connected to SSH!
==> Ubuntu-18.04: Provisioning with shell script: /tmp/packer-shell382031289
==> Ubuntu-18.04: sudo: no tty present and no askpass program specified
==> Ubuntu-18.04: Provisioning step had errors: Running the cleanup provisioner, if present...
==> Ubuntu-18.04: Stopping virtual machine...
==> Ubuntu-18.04: Destroying virtual machine...
Build 'Ubuntu-18.04' errored after 8 minutes 21 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]
==> Wait completed after 8 minutes 21 seconds
==> Some builds didn't complete successfully and had errors:
--> Ubuntu-18.04: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]
==> Builds finished but no artifacts were created.我做错了什么?
发布于 2021-02-19 23:36:56
您需要像这样告诉sudo从标准输入中读取数据:
echo 'password' | sudo -S echo "I am groot"这样,您的sudo命令就可以工作了。
https://stackoverflow.com/questions/66186534
复制相似问题