2
我想使用Packer爲使用廚師的amazon ebs配置映像。打包者Amazon EBS廚師 - 抱歉,您必須有一個tty才能運行sudo
我收到以下錯誤消息:
sudo: sorry, you must have a tty to run sudo
example.json
{
"builders": [{
"type": "amazon-ebs",
"access_key": "...",
"secret_key": "...",
"region": "eu-central-1",
"source_ami": "ami-daaeaec7",
"instance_type": "t2.micro",
"ssh_username": "ec2-user",
"ami_name": "packer-example {{timestamp}}"
}],
"provisioners": [{
"type": "chef-solo",
"cookbook_paths": ["cookbooks", "site-cookbooks"],
"run_list": [ ]
}]
}
輸出
$ packer build example.json
amazon-ebs output will be in this color.
==> amazon-ebs: Prevalidating AMI Name...
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Creating temporary keypair: packer ...
==> amazon-ebs: Creating temporary security group for this instance...
==> amazon-ebs: Authorizing access to port 22 the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
amazon-ebs: Instance ID: i-...
==> amazon-ebs: Waiting for instance (i-...) to become ready...
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Provisioning with chef-solo
amazon-ebs: Installing Chef...
amazon-ebs: % Total % Received % Xferd Average Speed Time Time Time Current
amazon-ebs: Dload Upload Total Spent Left Speed
amazon-ebs: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0sudo: sorry, you must have a tty to run sudo
amazon-ebs: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (23) Failed writing body (0 != 16086)
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: No AMIs to cleanup
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' errored: Error installing Chef: Install script exited with non-zero exit status 1
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Error installing Chef: Install script exited with non-zero exit status 1
==> Builds finished but no artifacts were created.
我認爲相關的錯誤信息是:
sudo: sorry, you must have a tty to run sudo
有沒有人有想法?
謝謝,我會嘗試:) – Dennis
@寶馬,我很好奇你爲什麼提到這是一個解決方法。有更好的解決方案嗎?或者有些方法可以完全避免這個問題? – ZombieDev
我認爲當我回答這個問題時應該有更好的解決方案,但是到現在爲止還沒有其他人能夠回答。這個答案已經被多次接受和投票了,我更新了這個表達。 – BMW