簡體   English   中英

在創建打包程序 Ubuntu 映像時無法查明錯誤

[英]Cannot pinpoint error in creating a packer Ubuntu Image

我正在嘗試將 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調用外殼預配時。

{
  "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 /有關此參數的更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM