如何解决打包程序错误 - sudo:不存在 tty 且未指定 askpass 程序
这周我一直在我的家庭实验室学习如何使用 Packer,我有一台 ESXi 7 主机。
我只是想部署一个 Ubuntu 18.04 VM,但是在构建结束时,我在打包程序控制台中收到此错误:
sudo: no tty present and no askpass program specified
这就是我所做的。
我运行的命令:
sudo packer build -var-file=variables.json build.json
在 ESXi 中,我看到 VM 构建并完成并重新启动,它获得了一个 IP 并且我在看到上述消息后 Packer 删除 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.
我做错了什么?
解决方法
你需要告诉 sudo
像这样从标准输入读取:
echo 'password' | sudo -S echo "I am groot"
这样您的 sudo
命令应该可以工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。