使用Preseed在/etc/apt/sources.list中设置镜像源

3

我希望自动化创建我的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文件和完整的preseed_wheezy.cfg

我很乐意听取每个建议。


你是否曾经了解过 Packer 的 preseed 文件应该是什么样子的?如果了解,请添加一个答案! - Stefan Walter
1个回答

2
作为一种解决方法,我通过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的内容,但这个解决方案对我有效。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接