【问题标题】:Set mirrors in /etc/apt/sources.list with Preseed使用 Preseed 在 /etc/apt/sources.list 中设置镜像
【发布时间】:2014-10-05 07:51:52
【问题描述】:

我想自动创建我的 Debian 映像。

使用 Packer 0.7.1 和 Preseed 到目前为止效果很好,唯一我不能正确的是 /etc/apt/sources.list 的内容。

我希望它是这样的:

deb http://http.debian.net/debian wheezy main
deb-src http://http.debian.net/debian wheezy main

deb http://http.debian.net/debian wheezy-updates main
deb-src http://http.debian.net/debian wheezy-updates main

deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

使用我当前的脚本,我只能获得最后两行,这不足以通过apt-get install 安装软件。

这就是我尝试在我的preseed_wheezy.cfg 中设置镜像和 apt 的方式:

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string http.debian.net
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
d-i mirror/suite string wheezy

### Apt setup
d-i apt-setup/use_mirror boolean true
d-i apt-setup/hostname      string http.debian.net
d-i apt-setup/directory     string /debian/
d-i apt-setup/non-free  boolean true
d-i apt-setup/contrib   boolean true
d-i apt-setup/security-updates      boolean true
d-i apt-setup/security-updates-fail string security.debian.org

apt-mirror-setup apt-setup/use_mirror boolean true
apt-mirror-setup mirror/http/hostname    string http.debian.net
apt-mirror-setup apt-setup/contrib  boolean true
apt-mirror-setup apt-setup/non-free     boolean true

此外,这是我的packer JSON file 和完整的preseed_wheezy.cfg

我对每个建议都很满意。

【问题讨论】:

  • 您有没有发现 Packer 的预置文件应该是什么样子的?如果有,请添加答案!

标签: debian apt packer


【解决方案1】:

作为一种解决方法,这是我通过 Packer .json 文件配置我的 sources.list 的方式:

{
  "type": "shell",
  "execute_command": "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'",
  "inline": [
    "echo deb http://security.debian.org/ wheezy/updates main > /etc/apt/sources.list",
    "echo deb http://http.debian.net/debian wheezy main >> /etc/apt/sources.list",
    "echo deb http://http.debian.net/debian wheezy-updates main >> /etc/apt/sources.list",

    "apt-get update" ,
    "apt-get install python-pip python-dev git -y",
    "pip install PyYAML jinja2 paramiko httplib2",
    "pip install ansible",

  ]
},

虽然我没有让 Preseed 设置 sources.list 的内容,但这个解决方案对我有用。

【讨论】:

    猜你喜欢
    • 2015-02-01
    • 1970-01-01
    • 2021-06-08
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    • 2012-08-27
    • 1970-01-01
    • 2012-01-05
    相关资源
    最近更新 更多