gpt4 book ai didi

amazon-web-services - 在创建打包程序 Ubuntu 镜像时无法查明错误

转载 作者:行者123 更新时间:2023-12-04 19:27:34 25 4
gpt4 key购买 nike

我正在尝试将 consul 构建为 ubuntu 打包程序镜像。 Packer 构建镜像,但存在一些问题。
具体是这个问题:

==> amazon-ebs: debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
==> amazon-ebs: debconf: falling back to frontend: Readline
==> amazon-ebs: debconf: unable to initialize frontend: Readline
==> amazon-ebs: debconf: (This frontend requires a controlling tty.)
==> amazon-ebs: debconf: falling back to frontend: Teletype
==> amazon-ebs: dpkg-preconfigure: unable to re-open stdin:
这是我的 Json 代码:
{
"variables": {
"aws_access_key": "{{ env `ACCESS_KEY` }}",
"aws_secret_key": "{{ env `SECRET_KEY` }}"
},

"builders": [{
"type": "amazon-ebs",
"ami_name": "consul-client",
"access_key": "{{ user `aws_access_key` }}",
"secret_key": "{{ user `aws_secret_key` }}",
"region": "eu-west-2",
"source_ami_filter": {

"filters": {

"name": "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*",

"root-device-type": "ebs",

"virtualization-type": "hvm"

},

"owners": ["099720109477"],

"most_recent": true

},
"instance_type": "t2.micro",
"ssh_username": "ubuntu"


}],

"provisioners": [{
"type": "shell",
"script": "./scripts/consul_client.sh"
}]
}

这是我正在运行的脚本:
#!/bin/bash

echo "Hello Consul Client!"

# Install Consul. This creates...
# 1 - a default /etc/consul.d/consul.hcl
# 2 - a default systemd consul.service file

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install -y consul

# Modify the default consul.hcl file
cat > /tmp/consul.hcl.tmp <<- EOF
data_dir = "/opt/consul"
client_addr = "0.0.0.0"
ui_config{
enabled = true
}
server = true
bind_addr = "0.0.0.0"
advertise_addr = "$local_ip"
bootstrap_expect=1
retry_join = ["provider=aws tag_key=Name tag_value=ConsulClient"]
EOF

sudo cp /tmp/consul.hcl.tmp /etc/consul.d/consul.hcl
rm -f /tmp/consul.hcl.tmp

# Start Consul
sudo systemctl start consul
在 AMI 部分的 AWS 控制台上,当源 ami 是 ubuntu 镜像时,平台显示为其他 Linux。出于某种原因,我觉得它没有正确制作,而且我也无法通过 SSH 连接到实例,我认为这可能是问题。

最佳答案

您应该能够通过设置 DEBIAN_FRONTEND 来解决此错误。环境变量为 noninteractive调用 shell 配置程序时。

{
"provisioners": [
{
"type": "shell",
"script": "./scripts/consul_client.sh",
"environment_vars": [
"DEBIAN_FRONTEND=noninteractive"
]
}
]
}
https://help.ubuntu.com/lts/installation-guide/amd64/ch05s03.htmlhttps://www.cyberciti.biz/faq/explain-debian_frontend-apt-get-variable-for-ubuntu-debian/有关此参数的更多信息。

关于amazon-web-services - 在创建打包程序 Ubuntu 镜像时无法查明错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69646219/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com